在尝试运行应用时遇到有关app:preDexDebug任务问题的项目存在问题。收到的错误是:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
当前设置:
Android Studio 0.8.1
Android Build Tools 20.0.0
Java 1.7_55
Windows 7
即使是默认项目也不会运行,尽管gradle sync构建正常。
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\...\AppData\Local\Android\android-sdk\build-tools\20.0.0\dx.bat --dex --output C:\...\TestApplication\app\build\intermediates\pre-dexed\debug\support-v4-19.1.0-c0d17b20b65717b1b327ef7ea8fea7e8a443e7fe.jar C:\...\AppData\Local\Android\android-sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar
Error Code:
1
Output:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.testapplication"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
答案 0 :(得分:0)
通过设置
解决(在Windows上)set _JAVA_OPTIONS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
现在脚本报告
拿起_JAVA_OPTIONS:-Xms512m -Xmx512m -XX:MaxPermSize = 256m 并且工作正常。
奇怪的是,设置变量GRADLE_OPTS和JAVA_OPTS没有效果。