使用Firestore会导致“没有静态方法checkArgument”

时间:2019-07-06 19:27:10

标签: android firebase google-cloud-firestore

所有相关文章似乎都表明Firebase和Playservices之间的版本不匹配,但是我找不到一个wrt。 Firestore。我尝试了各种排列,但没有找到解决方法。这是我的礼物:

dependencies {

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.google.android.material:material:1.0.0'

    //----------------------------------------------------------------------------------------------
    //---   FireBase
    //----------------------------------------------------------------------------------------------

    // Firebase DataBase
//    implementation 'com.google.firebase:firebase-database:18.0.0'
//    implementation 'com.google.firebase:firebase-auth:18.0.0'

    // Firebase Firestore
    // Need to exclude 'guava' to avoid dreaded 'Duplicate class' Errors during compile
    implementation ('com.google.firebase:firebase-firestore:20.1.0')
    {
        exclude group: 'com.google.guava'
    }

    //----------------------------------------------------------------------------------------------
    //---   Google Oauth and Google Sheets
    //----------------------------------------------------------------------------------------------

    implementation 'com.google.android.gms:play-services-auth:17.0.0'

    implementation 'pub.devrel:easypermissions:0.2.1'

    implementation('com.google.api-client:google-api-client-android:1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }

    implementation('com.google.apis:google-api-services-sheets:v4-rev465-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'
    }


}

我试图将其与playservices对齐。 17.0.0,也尝试了18.x版本,但无济于事。有趣的是,当我使用Firebase实时数据库时,它可以正常工作,因此那里没有不兼容之处。但是我想切换到Firestore以便在我要写入/读取的类中利用更好的ArrayList处理。

我还必须排除guava组,否则我将得到那些“重复的类”错误(同样,仅使用Firestone,而不使用数据库)。

这是完整的日志:

2019-07-06 12:12:48.397 1671-1684/? E/memtrack: Couldn't load memtrack module
2019-07-06 12:12:48.541 7857-7857/com.mairyu.app.lingoflash E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mairyu.app.lingoflash, PID: 7857
    java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
        at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore@@18.0.0:379)
        at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.NoSuchMethodError: No static method checkArgument(ZLjava/lang/String;I)V in class Lcom/google/common/base/Preconditions; or its super classes (declaration of 'com.google.common.base.Preconditions' appears in /data/app/com.mairyu.app.lingoflash-_VKmE7anO3pKy3BbdIRr4w==/base.apk)
        at com.google.firebase.Timestamp.validateRange(com.google.firebase:firebase-firestore@@18.0.0:160)
        at com.google.firebase.Timestamp.<init>(com.google.firebase:firebase-firestore@@18.0.0:65)
        at com.google.firebase.firestore.model.SnapshotVersion.<clinit>(com.google.firebase:firebase-firestore@@18.0.0:26)
        at com.google.firebase.firestore.local.SQLiteQueryCache.<init>(com.google.firebase:firebase-firestore@@18.0.0:40)
        at com.google.firebase.firestore.local.SQLitePersistence.<init>(com.google.firebase:firebase-firestore@@18.0.0:111)
        at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore@@18.0.0:226)
        at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore@@18.0.0:114)
        at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(Unknown Source:8)
        at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore@@18.0.0:311)
        at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(Unknown Source:2)
        at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore@@18.0.0:287)
        at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@18.0.0:205)
        at java.lang.Thread.run(Thread.java:764)

1 个答案:

答案 0 :(得分:0)

在我非常相似的情况下,问题是因为我没有尝试将Guava从Firestore之外的某些依赖项中排除。所以起初我有类似的实现(只是使用新版本)

implementation ('com.google.firebase:firebase-firestore:21.3.1') {
    exclude group: 'com.google.guava'
}

,但是后来我尝试将排除转移到另一个负担得起且可以接受的依赖项。对我来说是google api客户端:

implementation ('com.google.api-client:google-api-client:1.22.0') {
    exclude group: 'com.google.guava'
}

因此,我没有排除Firestore依赖,现在一切正常。

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