簡體   English   中英

構建APK時Android Studio中出現錯誤消息

[英]Error message occurs in Android studio when build APK

我在Android Studio中完成了我的編碼部分。 然后,我運行構建APK並發生突然錯誤。

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.

如錯誤消息中所示,您只需將此代碼添加到build.gradle:

 android {
        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }
    }

並添加為@Ranjan Kumar說,min sdk android版本:

 android {
          defaultConfig {
            minSdkVersion 26
         }
    }

如錯誤日志中所示,請執行以下更改之一。

1. In app/build.gradle, add compileoptions for java 1.8 in android block.



     android {
          ...
          // Configure only for each module that uses Java 8
          // language features (either in its source code or
          // through dependencies).
          compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
          }

        }

2. change minSDKVersion to 26.


     android {
          ...

          // change minSDKVersion to 26
          defaultConfig {
            ...
            minSdkVersion 26
           ....
        }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM