Apollo-android: Crash on android 4

Created on 14 May 2020  路  13Comments  路  Source: apollographql/apollo-android

Summary
app crash on android 4

Description
after update to 2.0.2 app crash on android 4
Version
2.0.2

Bug

All 13 comments

Please provide more info, what was the crash?

I just updated apollo version from 1.2.3 to 2.0.2 and app crashed in android 4.4.2 and android 4.4.4 .
app crash in start with this exception :

05-14 21:33:16.527 9654-9654/ir.basalam.app.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ir.basalam.app.debug, PID: 9654
    java.lang.ExceptionInInitializerError
        at okhttp3.internal.platform.Android10Platform.<clinit>(Android10Platform.kt:67)
        at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:206)
        at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:169)
        at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:170)
        at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:232)
        at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1052)
        at com.google.firebase.inappmessaging.display.internal.injection.modules.PicassoModule.providesFiamController(com.google.firebase:firebase-inappmessaging-display@@19.0.6:46)
        at com.google.firebase.inappmessaging.display.internal.injection.modules.PicassoModule_ProvidesFiamControllerFactory.providesFiamController(com.google.firebase:firebase-inappmessaging-display@@19.0.6:43)
        at com.google.firebase.inappmessaging.display.internal.injection.modules.PicassoModule_ProvidesFiamControllerFactory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:32)
        at com.google.firebase.inappmessaging.display.internal.injection.modules.PicassoModule_ProvidesFiamControllerFactory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:11)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.google.firebase.inappmessaging.display.internal.FiamImageLoader_Factory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:21)
        at com.google.firebase.inappmessaging.display.internal.FiamImageLoader_Factory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:8)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay_Factory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:57)
        at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay_Factory.get(com.google.firebase:firebase-inappmessaging-display@@19.0.6:16)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.google.firebase.inappmessaging.display.internal.injection.components.DaggerAppComponent.providesFirebaseInAppMessagingUI(com.google.firebase:firebase-inappmessaging-display@@19.0.6:80)
        at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplayRegistrar.buildFirebaseInAppMessagingUI(com.google.firebase:firebase-inappmessaging-display@@19.0.6:74)
        at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplayRegistrar.access$lambda$0(com.google.firebase:firebase-inappmessaging-display@@19.0.6)
        at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplayRegistrar$$Lambda$1.create(com.google.firebase:firebase-inappmessaging-display@@19.0.6)
        at com.google.firebase.components.ComponentRuntime.lambda$new$0(com.google.firebase:firebase-components@@16.0.0:69)
        at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(com.google.firebase:firebase-components@@16.0.0)
        at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-components@@16.0.0:53)
        at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-components@@16.0.0:158)
        at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@19.3.0:563)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:304)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:268)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:253)
        at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.3.0:51)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1638)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1609)
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.3.0:45)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5008)
        at 

it's ok in android > 5 but crash in android 4
and when i revert version to 1.2.3 it's run normally.
!!

This happens because apollo-runtime now depends on OkHttp version 4+ that requires Android 5+.

I'll try to see if we can keep using OkHttp 3.12 in the next 2+ version. In the meantime, you can use version 1.4.5 that is still on OkHttp 3.12

Thank you @martinbonnin. It's very good. I'm waiting for that version.
I switch to version 1.4.5 for now but the following errors occurred in build :

C:\Users\...\app\build\generated\source\apollo\debug\service\ir\basalam\app\graphql\CreatePostProductSearchQuery.java:40: error: CreatePostProductSearchQuery is not abstract and does not override abstract method composeRequestBody(boolean,boolean,ScalarTypeAdapters) in Query
public final class CreatePostProductSearchQuery implements Query<CreatePostProductSearchQuery.Data, CreatePostProductSearchQuery.Data, CreatePostProductSearchQuery.Variables> {

C:\Users\...\app\build\generated\source\apollo\debug\service\ir\basalam\app\graphql\CreatePostMutation.java:40: error: CreatePostMutation is not abstract and does not override abstract method composeRequestBody() in Operation
public final class CreatePostMutation implements Mutation<CreatePostMutation.Data, CreatePostMutation.Data, CreatePostMutation.Variables> {

That sounds like you still have apollo-runtime:2.0.x somewhere in your dependencies. Can you double check ? Both apollo-gradle-plugin and apollo-runtime should have the same version for the generated code to match the runtime.

Both apollo-gradle-plugin and apollo-runtime are 1.4.5 :
classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.4.5'
implementation 'com.apollographql.apollo:apollo-runtime:1.4.5'

Interesting. composeRequestBody() shouldn't be in 1.4.5: https://github.com/apollographql/apollo-android/blob/v1.4.5/apollo-api/src/main/java/com/apollographql/apollo/api/Operation.java

Maybe try with --no-build-cache ?

I tried for --no-build-cache also cleanBuildCache also clean gradle cache but nothing changed and that error occurred again.!!!

Can you run ./gradlew :app:dependencies to see what version of apollo-api is used ?

+--- com.apollographql.apollo:apollo-runtime:1.4.5 -> 2.0.2 (*)

I found problem. We have another module in project that used apollo version 2.0.2. I revert that module to 1.4.5 and every thing is ok .
thanks @martinbonnin

This is also going to be fixed with the next version thanks to #2269

Was this page helpful?
0 / 5 - 0 ratings