OneSignal与Google gms不兼容

时间:2018-04-04 07:31:45

标签: android onesignal gmsmapview

我收到此错误,您可以在下面看到。 我发现导致错误的原因是我的项目中的gms版本与Onesignal中使用的版本之间不兼容。

我已经检查了这些帖子中提出的每个解决方案:

https://github.com/OneSignal/OneSignal-Android-SDK/issues/286

https://stackoverflow.com/questions/43430401/android-nosuchmethoderror-no-static-method-zzyljava-lang-object/43430478#comment86259725_43430478

Couldn't add OneSignal's Gradle plugin as suggested by OneSignal's official site.

卸下  申请插件:' com.google.gms.google-services' 和  classpath' com.google.gms:google-services:3.2.0' 从gradle文件中将解决此错误。但我不能这样做,因为我想在我的项目中夸大MapView,我需要google-services。

这是我得到的错误:

@Override
public void onBackPressed(){
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(MainHomeActivity.this);
    } else {
        builder = new AlertDialog.Builder(MainHomeActivity.this, AlertDialog.BUTTON_NEUTRAL);}
        builder.setTitle("Thank You");
        builder.setMessage("Thank You For Using Our Application Please Give Us Your Suggestions and Feedback ");
        builder.setNegativeButton("RATE US",
            new DialogInterface.OnClickListener(){
                public void onClick(DialogInterface dialog,int which){
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=ADD YOUR APPS PACKAGE NAME"));
                    startActivity(intent);
                    Toast.makeText(MainHomeActivity.this, "Thank you for your Rating",Toast.LENGTH_SHORT).show();
                }
            });
        builder.setPositiveButton("QUIT",new DialogInterface.OnClickListener(){
                public void onClick(DialogInterface dialog,int which){
                    finish();
                }
        });
        builder.show();
    }
}

我的build.gradle:

java.lang.NoSuchMethodError: No static method zza(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbq; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbq' appears in /data/app/com.blah.blah-1/base.apk:classes2.dex)
                      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                      at android.app.ActivityThread.installProvider(ActivityThread.java:6326)
                      at android.app.ActivityThread.installContentProviders(ActivityThread.java:5918)
                      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5857)
                      at android.app.ActivityThread.-wrap3(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6682)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

应用插件:&#39; com.google.gms.google-services&#39;

我的toplevel build.gradle:

apply plugin: 'com.android.application'
android {
        compileSdkVersion 27
        buildToolsVersion '27.0.3'
        defaultConfig
                {
                    applicationId "com.parsdigit.helsa"
                    manifestPlaceholders = [onesignal_app_id               : "4af7b2c1-a1a8-4b4a-ade3-d65289b38267",
                                            // Project number pulled from dashboard, local value is ignored.
                                            onesignal_google_project_number: "REMOTE"]
                    minSdkVersion 21
                    targetSdkVersion 27
                    versionCode 1
                    versionName "1.0"
                    vectorDrawables.useSupportLibrary = true
                    multiDexEnabled true
                }
        buildTypes
                {
                    release
                            {
                                minifyEnabled true
                                shrinkResources true
                                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                                debuggable true
                            }
                }
        aaptOptions {
            cruncherEnabled = false
        }

        packagingOptions
                {
                    exclude 'META-INF/DEPENDENCIES'
                    exclude 'META-INF/LICENSE'
                    exclude 'META-INF/LICENSE.txt'
                    exclude 'META-INF/license.txt'
                    exclude 'META-INF/NOTICE'
                    exclude 'META-INF/NOTICE.txt'
                    exclude 'META-INF/notice.txt'
                    exclude 'META-INF/ASL2.0'
                }

        lintOptions
                {
                    checkReleaseBuilds false
                }
        dexOptions
                {
                    preDexLibraries = false
                    jumboMode true
                    javaMaxHeapSize "4g"
                }
    }
dependencies
    {
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.squareup.okhttp3:okhttp:3.+'
        compile 'com.android.support:multidex:1.0.2'
        compile 'com.android.support:design:27.1.0'
        compile 'com.android.support:appcompat-v7:27.1.0'
        compile 'com.google.android.gms:play-services-maps:12.0.0'
        compile 'com.android.support:recyclerview-v7:27.1.0'
        compile 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
        compile 'org.apache.httpcomponents:httpclient:4.5.4'
        compile 'com.google.maps.android:android-maps-utils:0.4.3'
        compile 'com.google.code.gson:gson:2.8.2'
        compile 'uk.co.chrisjenx:calligraphy:2.2.0'
        compile 'com.pixplicity.easyprefs:library:1.8.1@aar'
        compile 'gun0912.ted:tedpermission:1.0.3'
        compile 'com.kennyc:snackbar:2.5'
        compile 'me.itangqi.waveloadingview:library:0.3.5'
        compile 'com.daimajia.androidanimations:library:2.3@aar'
        compile 'com.fujiyuu75:sequent:0.2.1'
        compile 'pl.charmas.android:android-reactive-location:0.10@aar'
        compile 'io.reactivex:rxjava:1.2.0'
        compile 'me.zhanghai.android.materialratingbar:library:1.2.0'
        compile 'cn.lightsky.infiniteindicator:library:1.2.2'
        compile 'de.hdodenhof:circleimageview:2.2.0'
        compile 'com.github.wooplr:Spotlight:1.2.3'
        compile 'com.caverock:androidsvg:1.2.1'
        compile 'com.github.bumptech.glide:glide:3.8.0'
        compile project(':sidemenulibrary')
        compile('com.github.ozodrukh:CircularReveal:1.1.1@aar') {
            transitive = true;
        }
        compile 'org.greenrobot:eventbus:3.0.0'
        compile 'com.nex3z:notification-badge:0.3.0'
        compile 'com.github.Shashank02051997:FancyGifDialog-Android:1.1'
        compile 'br.com.simplepass:loading-button-android:1.+'
        compile 'com.github.blennerSilva:AwesomeDialog:2.0.5'
        compile 'me.relex:circleindicator:1.2.2@aar'
        compile 'com.airbnb.android:lottie:2.2.5'
        compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
        compile 'com.github.RobertApikyan:SegmentedControl:release_1.0.1'
        compile 'com.github.skydoves:powermenu:2.0.1'
        compile 'com.otaliastudios:cameraview:1.4.1'
        compile 'com.github.Mostafa-MA-Saleh:EditCredit:1.5.0'
        compile 'com.github.mreram:ShowCaseView:1.0.5'
        compile 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
        compile 'com.alirezaafkar:sundatepicker:2.0.8'
        compile('com.cedarmaps:CedarMapsSDK:2.0.0@aar') {
            transitive = true
        }
    }
afterEvaluate
    {
        tasks.matching
        {
            it.name.startsWith('dex')
        }
        .each
                { dx ->
                    if (dx.additionalParameters == null) {
                        dx.additionalParameters = ['--multi-dex']
                    } else {
                        dx.additionalParameters += '--multi-dex'
                    }
                }
    }

1 个答案:

答案 0 :(得分:1)

POOOH!经过长达数小时的挣扎后,最终解决了这个问题:

变化          classpath'com.google.gms:google-services:3.2.0' 至         classpath'com.google.gms:google-services:3.2.1'

并更新             实现'com.google.android.gms:play-services-maps:12.0.0' 至             实施'com.google.android.gms:play-services-maps:12.0.1'