debugging Android Studio错误:android:需要显式指定已导出..... Android 12

ckx4rj1h  于 2022-11-14  发布在  Android
关注(0)|答案(1)|浏览(163)

我今天开始用AndroidStudio编程,一个朋友给我发了一个小的示例应用程序,但我无法运行任何代码,因为这个错误不断出现。我已经尝试解决它约3个小时,现在与不同的论坛,但我不能让它工作,我会非常感谢您的帮助,因为我只是不知道该怎么做....
控制台:

android:exported needs to be explicitly specified for element <activity#com.dbestech.food_delivery.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : android:exported needs to be explicitly specified for element <activity#com.dbestech.food_delivery.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
___________________________________________________________________________________

and my AndroidManifest.xml file:

___________________________________________________________________________________

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dbestech.food_delivery">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>```
xyhw6mcr

xyhw6mcr1#

将此添加到您的AndroidManifest.xml
您需要使用actionMAINcategoryLAUNCHER查找<activity>标记
像这样加上android:exported="true"-

<activity
   android:name=".MainActivity"
   android:exported="true">
      <intent-filter>
         <action android:name="android.intent.action.MAIN" />

         <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
 </activity>

相关问题