0

My app is crashing after I've added in-app updates and the play core library. Any ideas?

I'm using implementation "com.google.android.play:core:1.6.1" and the following code:

private val appUpdateManager by lazy { AppUpdateManagerFactory.create(this) }

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
        ) {
            appUpdateManager.startUpdateFlowForResult(
                appUpdateInfo,
                AppUpdateType.IMMEDIATE,
                this,
                REQUEST_CODE_APP_UPDATE
            )
        }
    }
}

It crashes right away with the following exception:

2019-06-27 09:42:10.320 10700-10771/? E/AndroidRuntime: FATAL EXCEPTION: AppUpdateService
    Process: com.example.app, PID: 10700
    java.lang.AbstractMethodError: abstract method "void com.google.android.play.core.internal.n.a()"
        at com.google.android.play.core.internal.n.run(Unknown Source:0)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)

Here's the app's build.gradle:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    id 'kotlin-kapt'
    id 'com.github.triplet.play' version '2.2.1'
    id 'realm-android'
    id 'io.fabric'
    id 'com.google.android.gms.oss-licenses-plugin'
}

if (!project.hasProperty('devBuild')) {
    apply plugin: 'com.google.firebase.firebase-perf'
}

def buildNumber = 36888

android {
    defaultConfig {
        applicationId "com.example"
        versionCode buildNumber
        versionName "1.8.11"

        resConfigs "en", "de"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release

            proguardFiles fileTree('./proguardrules').asList().toArray()
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            signingConfig signingConfigs.debug
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        pickFirst  'META-INF/*'
    }
}

androidExtensions {
    experimental = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation "androidx.cardview:cardview:$versions.androidx.cardview"
    implementation "androidx.constraintlayout:constraintlayout:$versions.androidx.constraint_layout"
    implementation "androidx.core:core-ktx:$versions.androidx.core_ktx"
    implementation "androidx.drawerlayout:drawerlayout:$versions.androidx.drawerlayout"
    implementation "androidx.fragment:fragment-ktx:$versions.androidx.fragment_ktx"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$versions.androidx.lifecycle"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.androidx.lifecycle"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$versions.androidx.lifecycle"
    implementation "androidx.preference:preference:$versions.androidx.preference"
    implementation "androidx.work:work-runtime-ktx:$versions.androidx.work"
    implementation "com.afollestad.material-dialogs:core:$versions.material_dialogs"
    implementation "com.afollestad.material-dialogs:input:$versions.material_dialogs"
    implementation "com.afollestad:vvalidator:$versions.vvalidator"
    implementation "com.crashlytics.sdk.android:crashlytics:$versions.crashlytics.core"
    implementation "com.google.android.material:material:$versions.androidx.material"
    implementation "com.google.android.gms:play-services-location:$versions.play_services.location"
    implementation "com.google.android.gms:play-services-maps:$versions.play_services.maps"
    implementation "com.google.android.play:core:$versions.play_services.core"
    implementation "com.google.firebase:firebase-core:$versions.firebase.core"
    implementation "com.google.firebase:firebase-config:$versions.firebase.config"
    implementation "com.google.firebase:firebase-perf:$versions.firebase.perf"
    implementation "com.xwray:groupie:$versions.groupie"
    implementation "com.xwray:groupie-kotlin-android-extensions:$versions.groupie"
    implementation "net.danlew:android.joda:$versions.joda_time_android"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin.core"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.kotlin.coroutines"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlin.coroutines"
    implementation "org.jetbrains.anko:anko-commons:$versions.anko"
    implementation "org.jetbrains.anko:anko-coroutines:$versions.anko"
}

play {
    serviceAccountCredentials = file('api-abc.json')
    defaultToAppBundles = true
    track = 'internal'
}

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
hardysim
  • 2,756
  • 2
  • 25
  • 52
  • Can you share your app.gradle please? – Anupam Jun 27 '19 at 07:59
  • Sure, question is updated with the app's `build.gradle`. – hardysim Jun 27 '19 at 11:55
  • Checking the issue. – Anupam Jun 27 '19 at 12:32
  • Updates: When compiling a release version locally, there are no crashes. It seems that this starts to happen when I install and start the version provided via the Play Store (published as an App Bundle via `com.github.triplet.play`). – hardysim Jun 27 '19 at 12:45
  • Can you try with minifyEnabled false in your gradle once. – Anupam Jun 27 '19 at 12:52
  • Now its getting weird. Downloading the AAB from the Play Store Console, extracting and installing it directly to the device via BundleTool is working (using the debug keystore). So I'm out of ideas. – hardysim Jun 27 '19 at 13:04
  • Using `minifyEnabled false` does not help. I first thought it's a ProGuard problem but then using a (local) release build shouldn't have worked. – hardysim Jun 27 '19 at 13:06
  • Yes. You are right – Anupam Jun 27 '19 at 13:11
  • Sry, `minifyEnabled false` *does* help (I was getting a cached download). If this is a ProGuard problem, why is my locally compiled release version with `minifyEnabled true` working? And is there any documentation that I need a ProGuard rule for this (and how does it look like)? – hardysim Jun 27 '19 at 13:11
  • Great. I will share soon – Anupam Jun 27 '19 at 13:17
  • You're gonna love it. Changed nothing (minified enabled etc.) and just published again - works like a charm. No crashes, no special tricks. Seems like a heisenbug. Thx for the help. – hardysim Jun 27 '19 at 13:27
  • Haha. Awesome :D – Anupam Jun 27 '19 at 13:37

0 Answers0