java.lang.RuntimeException: Internal error in Fire

2019-07-29 16:15发布

问题:

I am getting below error after updating from firestore:17.0.1 to firestore:17.0.2

java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
        at com.google.firebase.firestore.g.zza.zzb(SourceFile:324)
        at com.google.firebase.firestore.g.zzd.run(Unknown Source)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:7331)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
     Caused by: java.lang.AssertionError: impossible
        at java.lang.Enum$1.create(Enum.java:45)
        at java.lang.Enum$1.create(Enum.java:35)
        at libcore.util.BasicLruCache.get(BasicLruCache.java:54)
        at java.lang.Enum.getSharedConstants(Enum.java:211)
        at java.util.EnumSet.noneOf(EnumSet.java:48)
        at io.opencensus.trace.Span.<clinit>(Span.java:58)
        at io.opencensus.trace.SpanBuilder$NoopSpanBuilder.startSpan(SpanBuilder.java:238)
        at io.grpc.internal.CensusTracingModule$ClientCallTracer.<init>(CensusTracingModule.java:240)
        at io.grpc.internal.CensusTracingModule.newClientCallTracer(CensusTracingModule.java:122)
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor.interceptCall(CensusTracingModule.java:381)
        at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.interceptCall(CensusStatsModule.java:654)
        at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104)
        at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:560)
        at com.google.firebase.firestore.g.zzm.zza(SourceFile:61)
        at com.google.firebase.firestore.f.zza.zza(SourceFile:193)
        at com.google.firebase.firestore.f.zzo.zzk(SourceFile:332)
        at com.google.firebase.firestore.f.zzo.zza(SourceFile:256)
        at com.google.firebase.firestore.b.zzab.zza(SourceFile:162)
        at com.google.firebase.firestore.b.zzd.zza(SourceFile:79)
        at com.google.firebase.firestore.b.zzf.zzc(SourceFile:132)
        at com.google.firebase.firestore.b.zzn.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at com.google.firebase.firestore.g.zza$zza.run(SourceFile:190)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.NoSuchMethodException: values []
        at java.lang.Class.getMethod(Class.java:624)
        at java.lang.Class.getDeclaredMethod(Class.java:586)
        at java.lang.Enum$1.create(Enum.java:41)
        at java.lang.Enum$1.create(Enum.java:35) 
        at libcore.util.BasicLruCache.get(BasicLruCache.java:54) 
        at java.lang.Enum.getSharedConstants(Enum.java:211) 
        at java.util.EnumSet.noneOf(EnumSet.java:48) 
        at io.opencensus.trace.Span.<clinit>(Span.java:58) 
        at io.opencensus.trace.SpanBuilder$NoopSpanBuilder.startSpan(SpanBuilder.java:238) 
        at io.grpc.internal.CensusTracingModule$ClientCallTracer.<init>(CensusTracingModule.java:240) 
        at io.grpc.internal.CensusTracingModule.newClientCallTracer(CensusTracingModule.java:122) 
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor.interceptCall(CensusTracingModule.java:381) 
        at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104) 
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.interceptCall(CensusStatsModule.java:654) 
        at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:104) 
        at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:560) 
        at com.google.firebase.firestore.g.zzm.zza(SourceFile:61) 
        at com.google.firebase.firestore.f.zza.zza(SourceFile:193) 
        at com.google.firebase.firestore.f.zzo.zzk(SourceFile:332) 
        at com.google.firebase.firestore.f.zzo.zza(SourceFile:256) 
        at com.google.firebase.firestore.b.zzab.zza(SourceFile:162) 
        at com.google.firebase.firestore.b.zzd.zza(SourceFile:79) 
        at com.google.firebase.firestore.b.zzf.zzc(SourceFile:132) 
        at com.google.firebase.firestore.b.zzn.run(Unknown Source) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154) 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
        at com.google.firebase.firestore.g.zza$zza.run(SourceFile:190) 
        at java.lang.Thread.run(Thread.java:818) 

Here is my code which I am using for Firestore:

  public void fetchDataFromFireStore(final String uuid) {
        FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
        Query query = firebaseFirestore.collection(Constants.FirebaseConstants.USER_SPECIFIC_POST).document(uuid).collection(Constants.FirebaseConstants.POST).limit(postPerPageLimit).orderBy(Constants.FirebaseConstants.CREATED_DATE, Query.Direction.DESCENDING);
        query.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            @Override
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                int count = 0;
                if (task.isSuccessful()) {
                    if (task.getResult().size() == 0) {
                        mProgressBar.setVisibility(View.GONE);
                        textViewNoPost.setVisibility(View.VISIBLE);
                    } else {
                        mPostRecyclerAdapter.clearPostList();
                        for (DocumentSnapshot postDocumentSnapshot : task.getResult()) {
                            count++;
                            Post post = postDocumentSnapshot.toObject(Post.class);
                            if (post != null)
                                mPostRecyclerAdapter.addMyPost(new Post(post.getUserName(), post.getPost(), post.getPostOwnerUuid(), "", post.getTotalLikes(), post.getPostTime(), post.getCategoryName()));
                            if (count == postPerPageLimit) {
                                documentSnapshot = postDocumentSnapshot;
                            }
                        }
                    }
                    mProgressBar.setVisibility(View.GONE);
                    mPostRecyclerAdapter.setCurrentUserUID(uuid);
                    mRecyclerView.setAdapter(mPostRecyclerAdapter);
                }
            }
        });
    }

Gradle:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    //Gif drawable
    implementation 'com.thoughtbot:expandablerecyclerview:1.3'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    implementation 'com.google.firebase:firebase-firestore:17.0.2'
    implementation 'com.google.firebase:firebase-invites:16.0.1'
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-config:16.0.0'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.ss.bannerslider:bannerslider:2.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true
    }

It was working fine but after updating Firestore version is giving me this errors. Before asking this question I tried all possible solution available on stackoverflow/internet but didn't got any luck on it.

回答1:

From firebase support reply I solved this issue by adding below to progauard rule in future if someone facing this issue try this solution:

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}


回答2:

To solve this, please add the following line of code in your build.gradle file:

implementation 'com.google.firebase:firebase-core:16.0.1'

According to the official documentation:

Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.

Don't also forget to add in your top level build.gradle file the latest version of Google Play Services:

classpath 'com.google.gms:google-services:4.0.1'

Please see here more informations.



回答3:

I had this same issue and none of the solutions worked for me when I tried them individually. After trying out various combinations that were already posted and trying out downgrading and upgrading dependencies, finally the solution below worked for me:

First, ensure you have these versions in your project level build.gradle file:

classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'

Secondly, ensure you have these versions in your app level build.gradle file:

implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.google.firebase:firebase-firestore:17.0.1'

After this, if you have build and/or sync issues, replace

implementation 'com.google.firebase:firebase-firestore:17.0.1'

with the below code having the exclusions that prevents your build to finish successfully: (in my case these 3 exclusions were needed)

implementation('com.google.firebase:firebase-firestore:17.0.1') {
    exclude group: 'com.squareup.okio'
    exclude group: 'com.google.guava'
    exclude group: 'com.google.code.gson'
}

Also, ensure you have this at the end of your app level build.gradle file:

apply plugin: 'com.google.gms.google-services'

Furthermore, you need to have this in your proguard-rules.pro file:

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

Only after applying all these did my app work properly! I hope that it will help someone...