我刚刚切换到Android Studio 2.1,当尝试编译之前正在运行的应用程序时出现此错误:
Run Code Online (Sandbox Code Playgroud)Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file.
我已经更新了主项目的gradle.build文件以强制生成Java 1.7代码:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
}
Run Code Online (Sandbox Code Playgroud)
我还更新了gradle.build模块,如下所示设置java版本:
android …Run Code Online (Sandbox Code Playgroud) 我无法在调试和发布模式下使用 minifyEnabled true 运行 apk。我参考了下面的链接,但没有一个对我有用。
1. Android-错误:执行失败的任务“:应用程序:transformClassesWithDexForRelease”
2.将字节码转换为 dex 时出错:原因:java.lang.RuntimeException: Exception parsing classes - Android studio 2.0 beta 6
下面是应用程序 build.gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId 'XX.XX.XXX'
minSdkVersion 21
targetSdkVersion 23
versionCode 9
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
sourceSets.main {
jni.srcDirs = [] //disable automatic ndk-build call
jniLibs.srcDir 'src/main/libs' //integrate your libs from libs instead of jniLibs
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the …Run Code Online (Sandbox Code Playgroud)