Android-AS编译失败,Invoke-customs are only supported starting with Android O

最近在开发当中遇到了一个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文件当中加入下面语句

android{
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

这是由于之前加入某个依赖,必须支持Java8导致的错误。希望对同样android开发的小伙伴有帮助。

你可能感兴趣的:(Android-AS编译失败,Invoke-customs are only supported starting with Android O)