首页 > 解决方案 > Google Places API Crash Javalite clash with other Firebase APIs

问题描述

When I leave the Google Places API on idle after initialization, the application crashes with the stack trace as described at the end of this description.

I initialize the Places API once and only once in the manner described below

if(!Places.isInitialized()) {
  val apiKey = loadApiKey()
  Places.initialize(getApplication(), apiKey)
}

val client = Places.createClient(getApplication())

After running the above method and left on idle, the application crashes with the following stack trace.

I am assuming this is happening because of a clash between my javalite libraries and the protobuf java libraries.

    java.lang.ExceptionInInitializerError
        at com.google.android.datatransport.cct.a.zze.zzb(com.google.android.datatransport:transport-backend-cct@@2.1.0:1)
        at com.google.android.datatransport.cct.zzc.send(com.google.android.datatransport:transport-backend-cct@@2.1.0:9)
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.logAndUpdateState(com.google.android.datatransport:transport-runtime@@2.1.0:121)
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.lambda$upload$1(com.google.android.datatransport:transport-runtime@@2.1.0:88)
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader$$Lambda$1.run(Unknown Source:8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.lang.RuntimeException: Unable to get message info for com.google.android.datatransport.cct.a.zze
        at com.google.protobuf.GeneratedMessageInfoFactory.messageInfoFor(GeneratedMessageInfoFactory.java:62)
        at com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory.messageInfoFor(ManifestSchemaFactory.java:143)
        at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:55)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:93)
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:107)
        at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:175)
        at com.google.android.datatransport.cct.a.zze.<clinit>(com.google.android.datatransport:transport-backend-cct@@2.1.0:2)
        at com.google.android.datatransport.cct.a.zze.zzb(com.google.android.datatransport:transport-backend-cct@@2.1.0:1) 
        at com.google.android.datatransport.cct.zzc.send(com.google.android.datatransport:transport-backend-cct@@2.1.0:9) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.logAndUpdateState(com.google.android.datatransport:transport-runtime@@2.1.0:121) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.lambda$upload$1(com.google.android.datatransport:transport-runtime@@2.1.0:88) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader$$Lambda$1.run(Unknown Source:8) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 
     Caused by: java.lang.UnsupportedOperationException
        at com.google.android.datatransport.cct.a.zze.dynamicMethod(com.google.android.datatransport:transport-backend-cct@@2.1.0:2)
        at com.google.protobuf.GeneratedMessageLite.dynamicMethod(GeneratedMessageLite.java:256)
        at com.google.protobuf.GeneratedMessageLite.buildMessageInfo(GeneratedMessageLite.java:284)
        at com.google.protobuf.GeneratedMessageInfoFactory.messageInfoFor(GeneratedMessageInfoFactory.java:60)
        at com.google.protobuf.ManifestSchemaFactory$CompositeMessageInfoFactory.messageInfoFor(ManifestSchemaFactory.java:143) 
        at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:55) 
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:93) 
        at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:107) 
        at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:175) 
        at com.google.android.datatransport.cct.a.zze.<clinit>(com.google.android.datatransport:transport-backend-cct@@2.1.0:2) 
        at com.google.android.datatransport.cct.a.zze.zzb(com.google.android.datatransport:transport-backend-cct@@2.1.0:1) 
        at com.google.android.datatransport.cct.zzc.send(com.google.android.datatransport:transport-backend-cct@@2.1.0:9) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.logAndUpdateState(com.google.android.datatransport:transport-runtime@@2.1.0:121) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader.lambda$upload$1(com.google.android.datatransport:transport-runtime@@2.1.0:88) 
        at com.google.android.datatransport.runtime.scheduling.jobscheduling.Uploader$$Lambda$1.run(Unknown Source:8) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 

There might be an issue with the library's protobuffer integration clashing with the one I am using within my application.

标签: androidfirebasekotlingoogle-cloud-platformgoogle-places-api

解决方案


As per this issue tracker I created and mentioned by the comments. https://issuetracker.google.com/issues/161157921.

For now, simply add the following to update the internal Places dependencies on Protobufer libraries until they push out a Places version > 2.3.0

    implementation 'com.google.android.datatransport:transport-runtime:2.2.3'
    implementation 'com.google.android.datatransport:transport-backend-cct:2.3.0'

推荐阅读