问题描述
我收到此错误,您可以在下面看到.我发现导致错误的原因是项目中的gms版本与Onesignal中使用的版本不兼容.
There is this error I get which you can see below.I found what causes the error is the incompatibility between the gms version in my project and the one used in Onesignal.
我已经检查了这些帖子中提出的每个解决方案:
I have checked every single solution proposed in these posts:
https://github.com/OneSignal/OneSignal-Android-SDK /issues/286
可以'按照OneSignal官方网站的建议添加OneSignal的Gradle插件.
移除 应用插件:"com.google.gms.google-services"和 classpath'com.google.gms:google-services:3.2.0'从gradle文件将解决此错误.但是我不能这样做,因为我想在我的项目中为MapView充气,并且我需要Google服务.
Removing apply plugin: 'com.google.gms.google-services'and classpath 'com.google.gms:google-services:3.2.0'from gradle files will solve this error. But I cannot do it since I want to inflate MapView in my project and I need google-services.
这是我得到的错误:
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)
我的build.gradle:
My 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'
}
}
}
应用插件:"com.google.gms.google-services"
apply plugin: 'com.google.gms.google-services'
我的顶级build.gradle:
My toplevel build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://repo.cedarmaps.com/android/" }
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://dl.bintray.com/kennyc1012/maven' }
maven { url "http://dl.bintray.com/glomadrian/maven" }
maven { url "https://maven.google.com" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
推荐答案
POOOH!经过几个小时的努力,终于通过以下方式解决了该问题:
POOOH! After struggling for a long couple of hours finally fixed the issue by:
变化中 classpath'com.google.gms:google-services:3.2.0'到 classpath'com.google.gms:google-services:3.2.1'
changing classpath 'com.google.gms:google-services:3.2.0'to 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'
and updating implementation 'com.google.android.gms:play-services-maps:12.0.0'to implementation 'com.google.android.gms:play-services-maps:12.0.1'
这篇关于OneSignal与Google GMS不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!