今天把項目全部從support替換成AndroidX,Android Studio的版本更新成3.5.1,報了一個很奇怪的錯,錯誤資訊如下:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'butterknife-runtime.aar (com.jakewharton:butterknife-runtime:10.2.0)' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=19}
> Execution failed for DexingTransform: C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\c0d9910fc7a4452c3be877d137ec3ad7\jars\classes.jar.
> Error while dexing.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
截圖如下:
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHL9EFVNhXWU5UMJRVT3V1MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL4AzNzMDMzcTMyIDMxkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
解決方法如下:給所有的 Module 加入jdk1.8
在App的build.gradle檔案中的android 下加入如下代碼即可解決 :
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}