最近在開發(fā)當(dāng)中遇到了一個Android Studio編譯失敗的錯誤,記錄一下傀广。
錯誤片段
編譯器報錯如下:
om.android.tools.r8.a: Invoke-customs are only supported starting with Android O (--min-api 26)
at com.android.tools.r8.dex.r.a(:291)
at com.android.tools.r8.dex.r.a(:98)
at com.android.tools.r8.dex.r.b(:188)
at com.android.tools.r8.dex.b.a(:63)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:322)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:66)
at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:36)
at com.android.tools.r8.dex.b.b(:46)
at com.android.tools.r8.D8.d(:92)
at com.android.tools.r8.D8.b(:1)
at com.android.tools.r8.utils.W.a(:30)
at com.android.tools.r8.D8.run(:11)
....
修正錯誤方法
我們在運行的app的build.gradle
文件當(dāng)中加入下面語句
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
這是由于之前加入某個依賴,必須支持Java8導(dǎo)致的錯誤美侦。希望對同樣android開發(fā)的小伙伴有幫助怒医。