【发布时间】:2017-01-15 18:39:41
【问题描述】:
Internet 似乎认为问题出在 [source&target]Compatibility 字段不是 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 同步似乎可以正常构建,但是当我运行或调试时,我最终得到以下错误:
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.properties。我是 Android Studio 和 Gradle 的新手,如果这很明显,我很抱歉。
项目 build.gradle 中包含以下内容:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
对此也有点困惑,但这似乎是正确的插件版本与 Android Studio 使用的 2.14.1 版本。对这些差异有些困惑,但请弄清楚它的有用信息。
有什么想法吗?
【问题讨论】:
标签: android android-studio gradle build.gradle