我今天开始用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>```
Stack Overflow用户
发布于 2022-10-20 14:58:54
将此添加到您的AndroidManifest.xml
中
您需要找到带有<activity>
标记的action
MAIN和LAUNCHER的category
标记
加上这样的android:exported="true"
–
<code class="language-javascript"> <span class="token operator"><</span>activity <span class="token literal-property property">android</span><span class="token operator">:</span>name<span class="token operator">=</span><span class="token string">".MainActivity"</span> <span class="token literal-property property">android</span><span class="token operator">:</span>exported<span class="token operator">=</span><span class="token string">"true"</span><span class="token operator">></span> <span class="token operator"><</span>intent<span class="token operator">-</span>filter<span class="token operator">></span> <span class="token operator"><</span>action android<span class="token operator">:</span>name<span class="token operator">=</span><span class="token string">"android.intent.action.MAIN"</span> <span class="token operator">/</span><span class="token operator">></span> <span class="token operator"><</span>category android<span class="token operator">:</span>name<span class="token operator">=</span><span class="token string">"android.intent.category.LAUNCHER"</span> <span class="token operator">/</span><span class="token operator">></span> <span class="token operator"><</span><span class="token operator">/</span>intent<span class="token operator">-</span>filter<span class="token operator">></span> <span class="token operator"><</span><span class="token operator">/</span>activity<span class="token operator">></span></code>