我正在使用以下命令从 firebase
获取令牌:
FirebaseInstanceId.getInstance().getToken();
一切都很好,但是当我在gradle中使用以下命令时,我会得到错误:
compile 'com.firebaseui:firebase-ui:0.6.2'
我的logcat是:
Process: ir.bitafaraz.dpnaadmin, PID: 17325
java.lang.NoSuchMethodError: com.google.android.gms.common.util.zzx.getNoBackupFilesDir
at com.google.firebase.iid.zzg.zzeC(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzd.zzb(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at ir.bitafaraz.dpnaadmin.LoginActivity.onClick(LoginActivity.java:250)
at android.view.View.performClick(View.java:4457)
at com.balysv.materialripple.MaterialRippleLayout$PerformClickEvent.run(MaterialRippleLayout.java:648)
at com.balysv.materialripple.MaterialRippleLayout$3.onAnimationEnd(MaterialRippleLayout.java:336)
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:818)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1078)
at android.animation.ValueAnimator.access$400(ValueAnimator.java:53)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:649)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:665)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:768)
at android.view.Choreographer.doCallbacks(Choreographer.java:581)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:754)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5333)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:711)
at dalvik.system.NativeStart.main(Native Method)
我的gradle是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "ir.bitafaraz.dpnaadmin"
minSdkVersion 17
targetSdkVersion 25
versionCode 16
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:palette-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.firebaseui:firebase-ui:0.6.2'
}
apply plugin: 'com.google.gms.google-services'
我将firebase更改为1.1.1,而firebase消息传递到10.0.1:
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
然后将此命令添加到Manifest.xml
中的应用标签:
tools:replace="android:supportsRtl"
并将此命令添加到gradle:
allprojects {
repositories {
jcenter()
// Required for 'com.firebaseui:firebase-ui:1.1.1'
maven {
url 'https://maven.fabric.io/public'
}
}
}