Ionic 3安装后的admob插件应用程序构建失败

时间:2018-02-15 03:44:15

标签: build ionic2 admob ionic3

  

当我在离子3中构建一个Android应用程序时,它就构建了。但每次构建失败后使用admobFree或admobPro插件后我都会收到此错误....   (由于帖子限制,我发布了最后几行错误)


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

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

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

BUILD FAILED in 3m 22s
38 actionable tasks: 12 executed, 26 up-to-date
(node:11476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

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

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

BUILD FAILED in 3m 22s

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?


C:\Users\SHEKH RAIES\Raies-Ionic\test\file-upload\upload>

1 个答案:

答案 0 :(得分:1)

我迟到了。但希望这可以帮助开发人员寻找答案。我经历了很多事情来解决这个问题。文档没有帮助。更改配置没有做任何事情。删除和读取平台没有帮助。等

以下是我修复此问题的方法。

打开文件 的项目文件夹/插件/科尔多瓦-的AdMob-SDK / plugin.xml的

检查这部分

<platform name="android">
    <preference name="PLAY_SERVICES_VERSION" default="11.0"/>
    <framework src="com.google.android.gms:play-services-base:$PLAY_SERVICES_VERSION" />
    <framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
</platform>

参见文件 project-folder / platforms / android / build.gradle (每次构建项目时此文件都会更改)

此依赖关系部分

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: "CordovaLib"))
    compile "com.android.support:appcompat-v7:23+"
    compile "com.google.android.gms:play-services-base:11.0"
    compile "com.google.android.gms:play-services-ads:11.0"
    compile "com.google.android.gms:play-services-analytics:+"
    compile "com.android.support:support-v4:27.+"
    // SUB-PROJECT DEPENDENCIES END
}

查看另一个文件 project-folder / platforms / android / project.properties

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:appcompat-v7:23+
cordova.gradle.include.1=com.synconset.imagepicker/odi-ignorelinterrors.gradle
cordova.gradle.include.2=com.synconset.imagepicker/odi-androidtarget.gradle
cordova.system.library.2=com.google.android.gms:play-services-base:11.0
cordova.system.library.3=com.google.android.gms:play-services-ads:11.0
cordova.system.library.4=com.google.android.gms:play-services-analytics:+
cordova.gradle.include.3=phonegap-plugin-barcodescanner/odi-barcodescanner.gradle
cordova.system.library.5=com.android.support:support-v4:27.+

我如何修复

1 - 更改了文件 的项目文件夹/插件/科尔多瓦-的AdMob-SDK / plugin.xml的

从11.0到+所以它看起来像这样

<platform name="android">
    <preference name="PLAY_SERVICES_VERSION" default="+"/>
    <framework src="com.google.android.gms:play-services-base:$PLAY_SERVICES_VERSION" />
    <framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
</platform>

2 - 构建(sudo ionic cordova build android)

就是这样。

构建后见文件 project-folder / platforms / android / build.gradle 依赖部分。看起来像这样

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: "CordovaLib"))
    compile "com.android.support:appcompat-v7:23+"
    compile "com.google.android.gms:play-services-base:11.0"
    compile "com.google.android.gms:play-services-ads:11.0"
    compile "com.google.android.gms:play-services-analytics:+"
    compile "com.android.support:support-v4:27.+"
    // SUB-PROJECT DEPENDENCIES END
}

project-folder / platforms / android / project.properties 看起来像这样

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:appcompat-v7:23+
cordova.gradle.include.1=com.synconset.imagepicker/odi-ignorelinterrors.gradle
cordova.gradle.include.2=com.synconset.imagepicker/odi-androidtarget.gradle
cordova.system.library.2=com.google.android.gms:play-services-base:+
cordova.system.library.3=com.google.android.gms:play-services-ads:+
cordova.system.library.4=com.google.android.gms:play-services-analytics:+
cordova.gradle.include.3=phonegap-plugin-barcodescanner/odi-barcodescanner.gradle
cordova.system.library.5=com.android.support:support-v4:27.+