Android平台构建在某些库更新后失败
我有一个ionic/cordova项目,如果工作正常,我可以像魅力一样构建和运行该应用程序。因为两天前发生了一些事情,建筑被破坏了。命令“cordova build android”每次都会失败,并显示以下错误消息:Android平台构建在某些库更新后失败,android,cordova,ionic-framework,Android,Cordova,Ionic Framework,我有一个ionic/cordova项目,如果工作正常,我可以像魅力一样构建和运行该应用程序。因为两天前发生了一些事情,建筑被破坏了。命令“cordova build android”每次都会失败,并显示以下错误消息: > Task :app:transformDexArchiveWithExternalLibsDexMergerForArm64Debug FAILED D8: Program type already present: android.support.v4.media.Me
> Task :app:transformDexArchiveWithExternalLibsDexMergerForArm64Debug FAILED
D8: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForArm64Debug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
这个问题在同一天开始发生在所有开发者的PC上,所以我确定这不是一个特定的系统配置更改
我想应该是图书馆更新了
我的环境信息是:
Ionic:
ionic (Ionic CLI) : 4.12.0 (/home/gustavo/.nvm/versions/node/v8.9.4/lib/node_modules/ionic)
Ionic Framework : ionic1 1.3.1
@ionic/v1-toolkit : not installed
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.0, (and 14 other plugins)
System:
Android SDK Tools : 26.1.1 (/home/gustavo/apps/android-studio-running)
NodeJS : v8.9.4 (/home/gustavo/.nvm/versions/node/v8.9.4/bin/node)
npm : 6.4.1
OS : Linux 4.4
Cordova插件列表包括:
acidhax.cordova.chromecast 0.0.1-alpha "Cordova ChromeCast"
com.example.hello 0.7.0 "Hello"
com.telerik.plugins.nativepagetransitions 0.6.5 "Native Page Transitions"
cordova-android-support-gradle-release 2.1.0 "cordova-android-support-gradle-release"
cordova-plugin-add-swift-support 1.7.2 "AddSwiftSupport"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-device-name 1.3.5 "Device-Name"
cordova-plugin-fullscreen 1.1.0 "cordova-plugin-fullscreen"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.5.0 "cordova-plugin-ionic-webview"
cordova-plugin-screen-orientation 1.4.2 "Screen Orientation"
cordova-plugin-sim 1.3.3 "SIM"
cordova-plugin-splashscreen 4.1.0 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
我试着一个接一个地删除每个插件,发现当删除“acidhax.cordova.chromecast”时,构建成功完成
所以我开始搜索这个插件的问题,并发现了一个类似的问题:,我遵循了那里的建议,但问题仍然存在。这是由于AndroidX插件版本,以及谷歌几天前所做的突破性改变 您应该能够通过添加以下插件来解决此问题:
ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter
然后cordova清理android
并重新构建
请务必使用Android SDK 28,我建议您也更新Cordova和ionic。很高兴我能提供帮助