【问题标题】:java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev) after updating Firestore versionjava.lang.RuntimeException:更新 Firestore 版本后 Firestore (0.6.6-dev) 出现内部错误
【发布时间】:2018-07-12 07:40:20
【问题描述】:

firestore:17.0.1 更新到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) 

这是我用于 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);
                }
            }
        });
    }

分级:

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
    }

它工作正常,但更新 Firestore 版本后出现此错误。在问这个问题之前,我尝试了 stackoverflow/internet 上所有可能的解决方案,但没有任何运气。

【问题讨论】:

  • 请添加您的 build.gradle 文件的内容。
  • @AlexMamo 编辑了我的问题,请看一下

标签: java android firebase build.gradle google-cloud-firestore


【解决方案1】:

从 firebase 支持回复中,如果有人遇到此问题,我会通过在 progauard 规则中添加以下内容来解决此问题:

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

【讨论】:

    【解决方案2】:

    要解决这个问题,请在您的build.gradle 文件中添加以下代码行:

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

    根据官方文档:

    您的应用 gradle 文件现在必须明确列出 com.google.firebase:firebase-core 作为 Firebase 服务按预期工作的依赖项。

    别忘了在您的顶级 build.gradle 文件中添加最新版本的 Google Play 服务:

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

    更多信息请查看here

    【讨论】:

    • 不幸的是它没有用,我添加了 firebase-core 依赖项,并且我正在使用最新版本的 Google Play 服务
    • 您是否尝试过降级到implementation 'com.google.firebase:firebase-firestore:17.0.1',是否有效?但请注意,还要保留 implementation 'com.google.firebase:firebase-core:16.0.1' 依赖项。
    • 您是否也尝试过清除设备上应用程序管理器中的数据?
    • 在这种情况下,提交错误报告。 firebase.google.com/support/contact/bugs-features
    • 你有什么答案吗?
    【解决方案3】:

    我遇到了同样的问题,当我单独尝试它们时,没有一个解决方案对我有用。在尝试了已经发布的各种组合并尝试降级和升级依赖项之后,最后下面的解决方案对我有用:

    首先,确保您的项目级别build.gradle文件中有这些版本:

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

    其次,确保您的 app 级别 build.gradle 文件中有这些版本:

    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'
    

    在此之后,如果您有构建和/或同步问题,请更换

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

    下面的代码包含阻止您的构建成功完成的排除项: (在我的情况下,需要这 3 个排除项)

    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'
    }
    

    另外,请确保您在 app 级别 build.gradle 文件的末尾有这个:

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

    此外,您需要在您的 proguard-rules.pro 文件中包含此内容:

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

    只有在应用所有这些之后,我的应用才能正常运行! 我希望它会对某人有所帮助...

    【讨论】:

      猜你喜欢
      • 2018-03-22
      • 2019-02-07
      • 2018-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2020-01-14
      相关资源
      最近更新 更多