互联网似乎认为问题在于[源和目标]兼容性字段不是1.7,但我改变了这一点,无论我做什么都似乎无法动摇错误。
从导入的Eclipse项目在Windows 10上运行Android Studio 2.2.3。我的配置是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.stuff.MyApp"
minSdkVersion 23
targetSdkVersion 25
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v13:25.1.0'
compile 'com.google.http-client:google-http-client-gson:1.22.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.guava:guava:21.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.apis:google-api-services-drive:v2-rev249-1.22.0'
compile 'org.jsoup:jsoup:1.10.2'
compile 'org.apache.commons:commons-lang3:3.5'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'com.google.api-client:google-api-client-jackson2:1.22.0'
compile 'com.google.http-client:google-http-client:1.22.0'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-sheets:v4-rev40-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
}
它似乎从build-Make Project或build.gradle sync正常构建,但是当我运行或调试时,我最终得到以下错误:
To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
AGPBI: {"kind":"error","text":"PARSE ERROR:","sources":[{}]}
AGPBI: {"kind":"error","text":"unsupported class file version 52.0","sources":[{}]}
AGPBI: {"kind":"error","text":"...while parsing com/google/common/annotations/Beta.class","sources":[{}]}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
:app:transformClassesWithDexForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
我甚至尝试将RAM用于gradle JVM,但我的eclipse项目似乎没有gradle.properties文件,只有gradle-wrapper.properties和local.properaties。我是Android Studio和Gradle的新手,很抱歉,如果这很明显。
项目build.gradle中包含以下内容:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
稍微讨论一下,但这似乎是Android Studio使用的版本2.14.1的正确插件版本。略微混淆这些差异,但要弄清楚它的有用信息。
有什么想法吗?
答案 0 :(得分:0)
这意味着您在IDE项目中配置的Java SDK版本位于用于编译类路径上的某些库的SDK之后。只需配置一个(我会去1.8)
答案 1 :(得分:0)
我有类似的问题。但我的compileOptions是
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
错误信息与您的一样
AGPBI: {"kind":"error","text":"PARSE ERROR:","sources":[{}]}
AGPBI: {"kind":"error","text":"unsupported class file version 52.0","sources":[{}]}
AGPBI: {"kind":"error","text":"...while parsing com/google/common/annotations/Beta.class","sources":[{}]}
AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]}
错误说是在削减com/google/common/annotations/Beta.class
我发现Beta.class
属于compile 'com.google.guava:guava:21.0'
所以我删除了番石榴的使用,错误消失了。 希望这会对你有所帮助。