简体   繁体   English

Gradle“ com.android.dex.DexException”构建了一个涉及cordova-plugin-googlemaps和ibm-mfp-push插件的应用程序。

[英]Gradle “com.android.dex.DexException” building an app involving cordova-plugin-googlemaps and ibm-mfp-push plugins.

I'm trying to build an Ionic app on Android platform, including ibm-mfp-push cordova pplugin and googlemaps cordova plugin. 我正在尝试在Android平台上构建Ionic应用程序,包括ibm-mfp-push cordova pplugin和googlemaps cordova插件。

Starting from a fresh Ionic app, I've imported the cordova ibm-mfp-push plugin first, and the android build completes successfully. 从一个新的Ionic应用程序开始,我首先导入了cordova ibm-mfp-push插件,并且android构建成功完成。 After importing the cordova-plugin-googlemaps , the gradle build breaks with the following (frequent) exception: 导入cordova-plugin-googlemaps ,gradle构建因以下(频繁)异常而中断:

:transformClassesWithDexForDebug

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzqm;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)

    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)

Following the common approach, I looked for all modules causing the conflict in my dependency tree: 按照通用方法,我在依赖项树中查找了引起冲突的所有模块:

[...]
compile - Classpath for compiling the main sources.
+--- com.ibm.mobilefirstplatform.clientsdk.android:core:1.+ -> 1.2.2
|    \--- com.squareup.okhttp:okhttp:2.4.0
|         \--- com.squareup.okio:okio:1.4.0
+--- com.ibm.mobilefirstplatform.clientsdk.android:push:1.+ -> 1.0.2
|    +--- com.android.support:appcompat-v7:23.0.0
|    |    \--- com.android.support:support-v4:23.0.0
|    |         \--- com.android.support:support-annotations:23.0.0
|    +--- com.ibm.mobilefirstplatform.clientsdk.android:core:1.1.0 -> 1.2.2 (*)
|    \--- com.google.android.gms:play-services:7.8.0
|         +--- com.google.android.gms:play-services-ads:7.8.0
|         |    +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0
|         |    |    +--- com.google.android.gms:play-services-basement:9.2.0
|         |    |    |    \--- com.android.support:support-v4:23.0.0 (*)
|         |    |    \--- com.google.android.gms:play-services-tasks:9.2.0
|         |    |         \--- com.google.android.gms:play-services-basement:9.2.0 (*)
|         |    +--- com.google.android.gms:play-services-analytics:7.8.0
|         |    |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         |    \--- com.google.android.gms:play-services-appindexing:7.8.0
|         |         \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-analytics:7.8.0 (*)
|         +--- com.google.android.gms:play-services-appindexing:7.8.0 (*)
|         +--- com.google.android.gms:play-services-appinvite:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-appstate:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-cast:7.8.0
|         |    +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         |    \--- com.android.support:mediarouter-v7:22.2.0
|         |         \--- com.android.support:appcompat-v7:22.2.0 -> 23.0.0 (*)
|         +--- com.google.android.gms:play-services-drive:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-fitness:7.8.0
|         |    +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         |    \--- com.google.android.gms:play-services-location:7.8.0 -> 9.2.0
|         |         +--- com.google.android.gms:play-services-base:9.2.0 (*)
|         |         \--- com.google.android.gms:play-services-basement:9.2.0 (*)
|         +--- com.google.android.gms:play-services-games:7.8.0
|         |    +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         |    \--- com.google.android.gms:play-services-drive:7.8.0 (*)
|         +--- com.google.android.gms:play-services-gcm:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-identity:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-location:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-maps:7.8.0 -> 9.2.0
|         |    +--- com.google.android.gms:play-services-base:9.2.0 (*)
|         |    \--- com.google.android.gms:play-services-basement:9.2.0 (*)
|         +--- com.google.android.gms:play-services-nearby:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-panorama:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-plus:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-safetynet:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-vision:7.8.0
|         |    \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         +--- com.google.android.gms:play-services-wallet:7.8.0
|         |    +--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
|         |    +--- com.google.android.gms:play-services-identity:7.8.0 (*)
|         |    \--- com.google.android.gms:play-services-maps:7.8.0 -> 9.2.0 (*)
|         \--- com.google.android.gms:play-services-wearable:7.8.0
|              \--- com.google.android.gms:play-services-base:7.8.0 -> 9.2.0 (*)
+--- com.google.android.gms:play-services-maps:+ -> 9.2.0 (*)
\--- com.google.android.gms:play-services-location:+ -> 9.2.0 (*)

[...]

Finally I excluded following modules: 最后,我排除了以下模块:

configurations {
    all*.exclude group: 'com.google.android.gms', module: 'play-services-analytics'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-appindexing'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-ads'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-gcm'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-plus'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-safetynet'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-wallet'
    all*.exclude group: 'com.google.android.gms', module: 'play-services-wearable'
}

Now, the build terminates successfully, but I've a ClassNotFoundException at runtime: 现在,构建成功终止,但是在运行时出现了ClassNotFoundException:

E/AndroidRuntime(17337): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(17337):    at android.os.AsyncTask$3.done(AsyncTask.java:305)
E/AndroidRuntime(17337):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
E/AndroidRuntime(17337):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
E/AndroidRuntime(17337):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime(17337):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:232)
E/AndroidRuntime(17337):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(17337):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(17337):    at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(17337): Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/gcm/GoogleCloudMessaging;
E/AndroidRuntime(17337):    at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPush$6.doInBackground(MFPPush.java:547)
E/AndroidRuntime(17337):    at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPush$6.doInBackground(MFPPush.java:541)
E/AndroidRuntime(17337):    at android.os.AsyncTask$2.call(AsyncTask.java:293)
E/AndroidRuntime(17337):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(17337):    ... 4 more
E/AndroidRuntime(17337): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.gcm.GoogleCloudMessaging" on path: DexPathList[[zip file "/data/app/com.dsg.Smokers-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(17337):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(17337):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(17337):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(17337):    ... 8 more
E/AndroidRuntime(17337):    Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.gcm.GoogleCloudMessaging
E/AndroidRuntime(17337):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(17337):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(17337):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(17337):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(17337):        ... 9 more
E/AndroidRuntime(17337):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

How can I fix my issue? 我该如何解决我的问题? Thanks a lot for your help. 非常感谢你的帮助。

Finally solved modifying the project.properties file in Android project, changing the following lines 最后解决了修改Android项目中的project.properties文件,更改以下几行的问题

cordova.system.library.1=com.google.android.gms:play-services-maps:9.2.0
cordova.system.library.2=com.google.android.gms:play-services-location:9.2.0

with the following: 具有以下内容:

cordova.system.library.1=com.google.android.gms:play-services-maps:7.8.0
cordova.system.library.2=com.google.android.gms:play-services-location:7.8.0

I think you just need to add the following in the dependency section of your application's build.gradle file: 我认为您只需要在应用程序的build.gradle文件的依赖项部分中添加以下内容:

dependencies 
 {
   compile "com.google.android.gms:play-services-gcm:9.0.0"
 }

Source: https://developers.google.com/cloud-messaging/android/client 来源: https//developers.google.com/cloud-messaging/android/client

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 意外的顶级异常:com.android.dex.DexException - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException 将字节码转换为dex:原因:com.android.dex.DexException:定义了多个dex文件 - converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义 Landroid/arch/lifecycle/liveData$1 - Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1 com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / location / places / PlaceReport; - com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/PlaceReport; 错误:com.android.dex.DexException:多个dex文件定义了Ledu / umd / cs / findbugs / annotations / NonNull; - Error:com.android.dex.DexException: Multiple dex files define Ledu/umd/cs/findbugs/annotations/NonNull; com.android.dex.DexException:多个dex文件定义了Lcom / facebook / internal / Utility $ GraphMeRequestWithCacheCallback; - com.android.dex.DexException: Multiple dex files define Lcom/facebook/internal/Utility$GraphMeRequestWithCacheCallback; com.android.dex.DexException:多个dex文件定义Lorg / hamcrest / Description; - com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description; 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst; - Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM