为什么我的android Koltin应用程序在android 12打开时崩溃(在其他os /模拟器上没有错误)?<



我有一个工作良好的android应用程序,在kotlin开发。我在应用级构建中将目标SDK更新为31。gradle文件,

plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
buildFeatures {
viewBinding true
}
compileSdkVersion 31
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.win.app"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
compileOptions.encoding = 'ISO-8859-1'
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// For Kotlin users also import the Kotlin extensions library for Play In-App Review:
implementation 'androidx.work:work-runtime:2.7.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.play:review:2.0.1'
implementation 'com.google.firebase:firebase-messaging-ktx:23.0.2'
implementation 'com.github.bumptech.glide:glide:4.9.0'
// For Kotlin users, also add the Kotlin extensions library for Play In-App Review:
testImplementation 'junit:junit:4.12'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//implementation 'com.google.android.gms:play-services-ads:18.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.airbnb.android:lottie:3.4.0"
}
repositories {
mavenCentral()
}

它适用于所有版本的android,除了android 12和android 13(但它运行在android 13模拟器)。请帮我解决这个问题我使用折旧方法网络信息(截至sdk 31,它已折旧)。这是导致开盘崩溃的原因吗?但它仍然可以在android 11设备和android 13模拟器上运行。

我试过了,

implementation 'androidx.work:work-runtime:2.7.1'

但它没有工作。

通过更新已弃用的方法解决了这个问题。

将此更新为Android 12 &13

compileSdkVersion 33
targetSdkVersion 33

最新更新