简体   繁体   中英

Can't build apk on Android Studio without minSdkVersion 28

I can't build apk of my app on Android Studio(3.5.3) due to the following error:

Dex file with version '39' cannot be used with min sdk level '23'.

But I can run it perfectly on the emulator or on my android device via adb. Changing the minSdkVersion to 28 solved the problem but I want to target older versions (I have olders apks built successfully with minSdkVersion 23).

Here's my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.axiel7.weeb"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "0.2.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.preference:preference:1.1.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
    implementation 'com.google.android.material:material:1.1.0'
}

通过将android studio更新到新的3.6版本解决

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM