我最近开始学习如何通过 Android Studio 对 Android 设备进行编程。在我今天早上升级到 Android Studio 3.4 之前,我的第一个应用运行良好。
我遇到以下编译错误:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Technical.gradle\caches\transforms-2\files-2.1\4f3f8638c6a9f961dae488a0387efb6b\jars\classes.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
有没有办法恢复到我以前的 Android Studio 版本?
如果不是,新版本中有什么变化导致创建 dex 文件失败?
我尝试按照建议在 gradle.properties 中添加 android.enableD8=true here但没有运气。
编辑#1:
还绑定(bind)了将 multiDexEnabled true 添加到应用 build.gradle 文件中的默认配置,但仍然存在相同的编译错误。
完整的构建文件...
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "qdivision.org.qrtracker"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.felHR85:UsbSerial:6.0.5'
}
最佳答案
尝试将以下内容添加到您的 app/build.gradle 中,以使您的 Android 项目编译与 Java 8 兼容。
android {
....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
....
}
关于android - 错误 : Invoke-customs are only supported starting with Android O (--min-api 26),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55812717/