Failed resolving dependencies due to OneSignal

2020-05-06 13:04发布

I found the following question: Failed to resolve: com.android.support:customtabs:[26.0.0,26.1.0] People marked it as duplicate (which is wrong ! see next sentence) or wrote something about Maven or cleaning project etc.

I have exactly the same problem for two days (failed to resolve customtabs and support-v4) and I did not change anything in my project which has been previously working. So I started looking for possible solutions and I found the problem - it is the OneSignal dependency - when I remove it, everything works fine. But I have already implemented notifications in my app - and don't know what to do now. I tried to compile the newest one (mentioned on OneSignal page)

compile 'com.onesignal:OneSignal:[3.6.0,3.99.99)'

But the result is same. Can anyone help?

UPDATE:

The problem can be very easy reproduced - please create a simple project and add this dependency mentioned below (it is from official OneSignal website https://documentation.onesignal.com/v3.0/docs/android-sdk-setup):

 compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'

UPDATE 2:

These are my dependencies:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:25.3.1'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'

Adding

maven {
        url "https://maven.google.com"
    }

to the build.gradle solved the problem with OneSignal, but now I have a problem with Firebase:

java.lang.NoSuchMethodError: No static method zzdD(Ljava/lang/String;)Z in class Lcom/google/android/gms/common/util/zzv; or its super classes (declaration of 'com.google.android.gms.common.util.zzv' 

2条回答
虎瘦雄心在
2楼-- · 2020-05-06 13:32

Remove 'f' from dependency. also, use [ brackets instead of ). its a typo.

    dependencies {
    compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}

and this code in your root gradle file

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
查看更多
疯言疯语
3楼-- · 2020-05-06 13:43

The error happens because you have some conflicted library in your dependency.

As in the documentation, it says:

Automatic Dependencies
OneSignal automatically adds the following dependencies;

  • com.google.android.gms - Version 11
  • com.android.support - Version 26

Please makes sure your project matches these versions if you run into a mismatch version error.

For more details see the All gms/firesbase libraries must use the exact same version specification section.

So, you need to remove or use the same dependencies in your project, something like this:

compile 'com.android.support:appcompat-v7:26.0.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:11.0.+'
compile 'com.google.firebase:firebase-database:11.0.+'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:26.0.+'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
查看更多
登录 后发表回答