uni-app 打包谷歌包的时候打包失败

uni-app 打包谷歌包的时候打包失败

操作步骤:

  • 打包谷歌包的时候打包失败

预期结果:

  • 打包谷歌包的时候打包失败

实际结果:

  • 打包谷歌包的时候打包失败

bug描述:

Appid: UNI EF819A0
[PackagePath]/app/AndroidManifest.xml Error:
android:exported needs to be explicitly specified for element . 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:processReleaseMainManifest’.
Manifest merger failed with multiple errors, see logs  
  • Try:
Run with --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
  • Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:processReleaseMainManifest’. …

| 开发环境 | 版本号 | 项目创建方式 |
|----------|--------|--------------|
| Windows 11 | 4.57 | HBuilderX |

更多关于uni-app 打包谷歌包的时候打包失败的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app 打包谷歌包的时候打包失败的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是Android 12的兼容性问题,需要在AndroidManifest.xml中为所有包含intent-filter的组件显式声明android:exported属性。

解决方案:

  1. 在项目manifest.json中配置"targetSdkVersion"为31
  2. 在原生插件或模块的AndroidManifest.xml中,为所有包含intent-filter的Activity、Service、Receiver等组件添加明确的exported属性:
<activity
    android:name=".YourActivity"
    android:exported="true|false">
    <intent-filter>
        ...
    </intent-filter>
</activity>
  1. 如果是uni原生插件引起的问题,需要更新插件版本或联系插件作者适配Android 12

  2. 也可以临时降低targetSdkVersion到30,但不推荐长期使用:

"app-plus": {
    "distribute": {
        "android": {
            "targetSdkVersion": 30
        }
    }
}
回到顶部