互联网似乎认为问题出在[source&target]Compatibility字段不是1.7,但我已经更改了,无论我做什么都无法摆脱错误。
在Windows 10上运行从Eclipse导入的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项目或build.gradle同步构建可以成功生成代码,但是当运行或调试时,最终会出现以下错误:
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
我甚至尝试提高gradle JVM的RAM,但我的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不同。对于这些差异感到有些困惑,但我觉得这是有用的信息。
有任何想法吗?