添加in-app updates和播放核心库后,我的应用程序崩溃了。有什么想法吗?
我正在使用implementation "com.google.android.play:core:1.6.1"
和以下代码:
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
)
}
}
}
它立即崩溃,但出现以下异常:
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)
这是应用程序的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'