Closed joen93 closed 7 years ago
Could you please provide the stack trace of your error? Gradle by default uses the newer version of a dependency when conflicts exist. Therefore, by declaring a newer version of a dependency in your build.gradle
, this one should be used, even for other dependencies relying on it. See Dependency Management in the Gradle docs.
You can also check this behavior by executing the dependencies
Gradle task.
Here's the stack trace:
03-03 12:30:18.922 9134-9134/com.mycompany.myapp.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.myapp.debug, PID: 9134
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable;
at com.patloew.rxwear.RxWear.<init>(RxWear.java:37)
at com.mycompany.api.manager.WearManagerImpl.<init>(WearManagerImpl.java:33)
at com.mycompany.myapp.app.AppModule.provideWearManager(AppModule.java:357)
at com.mycompany.myapp.app.AppModule_ProvideWearManagerFactory.get(AppModule_ProvideWearManagerFactory.java:31)
at com.mycompany.myapp.app.AppModule_ProvideWearManagerFactory.get(AppModule_ProvideWearManagerFactory.java:11)
at dagger.internal.ScopedProvider.get(ScopedProvider.java:46)
at com.mycompany.myapp.app.RestModule_ProvideMsisdnManagerFactory.get(RestModule_ProvideMsisdnManagerFactory.java:43)
at com.mycompany.myapp.app.RestModule_ProvideMsisdnManagerFactory.get(RestModule_ProvideMsisdnManagerFactory.java:14)
at dagger.internal.ScopedProvider.get(ScopedProvider.java:46)
at com.mycompany.myapp.activities.MainActivity_MembersInjector.injectMembers(MainActivity_MembersInjector.java:65)
at com.mycompany.myapp.activities.MainActivity_MembersInjector.injectMembers(MainActivity_MembersInjector.java:17)
at com.mycompany.myapp.app.DaggerAppComponent.inject(DaggerAppComponent.java:784)
at com.mycompany.myapp.activities.MainActivity.onCreate(MainActivity.java:130)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp.debug-1/base.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.mycompany.myapp.debug-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp.debug-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.patloew.rxwear.RxWear.<init>(RxWear.java:37)
at com.mycompany.api.manager.WearManagerImpl.<init>(WearManagerImpl.java:33)
at com.mycompany.myapp.app.AppModule.provideWearManager(AppModule.java:357)
at com.mycompany.myapp.app.AppModule_ProvideWearManagerFactory.get(AppModule_ProvideWearManagerFactory.java:31)
at com.mycompany.myapp.app.AppModule_ProvideWearManagerFactory.get(AppModule_ProvideWearManagerFactory.java:11)
at dagger.internal.ScopedProvider.get(ScopedProvider.java:46)
at com.mycompany.myapp.app.RestModule_ProvideMsisdnManagerFactory.get(RestModule_ProvideMsisdnManagerFactory.java:43)
at com.mycompany.myapp.app.RestModule_ProvideMsisdnManagerFactory.get(RestModule_ProvideMsisdnManagerFactory.java:14)
at dagger.internal.ScopedProvider.get(ScopedProvider.java:46)
at com.mycompany.myapp.activities.MainActivity_MembersInjector.injectMembers(MainActivity_MembersInjector.java:65)
at com.mycompany.myapp.activities.MainActivity_MembersInjector.injectMembers(MainActivity_MembersInjector.java:17)
at com.mycompany.myapp.app.DaggerAppComponent.inject(DaggerAppComponent.java:784)
at com.mycompany.myapp.activities.MainActivity.onCreate(MainActivity.java:130)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
My root build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-rc1'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
My app build.gradle
dependencies {
compile "com.android.support:multidex:1.0.1"
compile "com.google.android.gms:play-services-analytics:10.2.0"
compile "com.google.android.gms:play-services-base:10.2.0"
compile "com.google.android.gms:play-services-auth:10.2.0"
...
compile "com.patloew.rxwear:rxwear:1.3.0"
productionWearApp project(path: ':wear', configuration: 'productionRelease')
}
...
apply plugin: 'com.google.gms.google-services'
You explicitly have to add the play-services-wearable dependency to make the version override mechanism work. Try adding the following in your build.gradle, then it should work:
compile "com.google.android.gms:play-services-wearable:10.2.0"
That did the trick, thanks! 👍
I tried to use GMS 10.2.0, which compiled fine, but as soon a I ran the app it crashed because of a gms version conflict caused by this lib, using gms 9.8.0:
com.google.android.gms:play-services-wearable:9.8.0
Can you please add the gms dependencies in the main documentation for other people? This way the lib wouldn't have to update every time a new gms version is released (as requested in #4 ) and the developer using the lib could upgrade to a later gms version. Thanks