cordova 无法构建支持Android 12的离子Android APK

vsaztqbk  于 2022-11-24  发布在  Android
关注(0)|答案(1)|浏览(213)

我正在尝试构建我的离子应用程序来支持Android 12。它在Android 11之前运行良好,但不支持Android 12。
这是我一直以来的尝试:
package.json

“cordova-android”: “^9.1.0”

构建.gradle文件:

defaultBuildToolsVersion=“29.0.2”
defaultMinSdkVersion=22
defaultTargetSdkVersion=30
defaultCompileSdkVersion=30

config.xml文件:

preference name="android-targetSdkVersion" value="30"

==尝试将sdk增加到31==
package.json文件:

“cordova-android”: “^10.0.0”

构建.gradle文件:

defaultTargetSdkVersion=31
defaultCompileSdkVersion=31

config.xml文件:

preference name="android-targetSdkVersion" value="31"

MainActivity中添加了android:exported=“true”,该文件位于..\platforms\android\应用程序\src\main\Android清单. xml中
在运行此构建时,我收到以下错误:

FCMPlugin: Support for Gradle v4 or lower is deprecated. Please upgrade to a newer version.WARNING:: Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see Add build dependencies  |  Android Developers.
WARNING:: Using flatDir should be avoided because it doesn’t support any meta-data formats.

Task :app:processDebugMainManifest FAILED
…\platforms\android\app\src\main\AndroidManifest.xml Error:
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 <activity>  |  Android Developers for details.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ‘:app:processDebugMainManifest’.
Manifest merger failed : 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 <activity>  |  Android Developers 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface

BUILD FAILED in 3s
15 actionable tasks: 1 executed, 14 up-to-date
Command failed with exit code 1: …\platforms\android\gradlew cdvBuildDebug -b …\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.

cordova.cmd build android exited with exit code 1.

Re-running this command with the --verbose flag may provide more information.

我试过所有的论坛和帖子,似乎都不起作用。有人有办法让这个工作吗?

i7uq4tfw

i7uq4tfw1#

有一个issue #222与FCM Plugin仍然没有解决,所以我可能会建议你降级你的插件版本安装,直到它得到修复.

相关问题