在运行我的app时面临问题。如下所述获取错误:
Execution failed for task ':android-readerplus:dexDevDebug'.
> com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
logcat的:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Invalid maximum heap size: -Xmx4g
The specified size exceeds the maximum representable size.
:android-readerplus:newRelicDeinstrumentTask
[newrelic.info] Deinstrumenting...
Error:Execution failed for task ':android-readerplus:dexDevDebug'.
com.android.ide.common.process.ProcessException org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 53.666 secs
Information:1 error
Gradle控制台:
AGPBI: {"kind":"SIMPLE","text":"warning: string \u0027newtext\u0027 has no default translation.","position":{},"original":"warning: string \u0027newtext\u0027 has no default translation."}
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Invalid maximum heap size: -Xmx4g
The specified size exceeds the maximum representable size.
:android-readerplus:newRelicDeinstrumentTask
[newrelic.info] Deinstrumenting...
Error:Execution failed for task ':android-readerplus:dexDevDebug'.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 53.666 secs
Information:1 error
的build.gradle:
android {
signingConfigs {
debug {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
compileSdkVersion 22
buildToolsVersion '22.0.1'
def versionNumber = '1.28'
def propertiesFile = new File(project.rootDir, 'version.properties')
if (propertiesFile.canRead()) {
def Properties properties = new Properties()
properties.load(new FileInputStream(propertiesFile))
def fileVersionNumber = properties['version_number']
def fileVersionSequence = properties['version_sequence'].toInteger()
if(!versionNumber.equals(fileVersionNumber)) {
fileVersionSequence = 0
properties['version_number'] = versionNumber
}
fileVersionSequence++
properties['version_sequence'] = fileVersionSequence.toString()
properties.store(propertiesFile.newWriter(), null)
def DecimalFormat numberFormat = new DecimalFormat('000');
def name = versionNumber + '.' + numberFormat.format(fileVersionSequence)
defaultConfig {
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName name
applicationId "com.pearson.android.readerplus"
testApplicationId "com.pearson.android.readerplus.test"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
// Enabling multidex support.
multiDexEnabled true
}
}
else {
throw new GradleException("Could not read version.properties!")
}
repositories {
flatDir {
dirs 'libs'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
minifyEnabled true
proguardFile 'proguard-rules.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.debug
}
}
lintOptions {
abortOnError false
}
}
dependencies {
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'com.squareup.dagger', module: 'dagger'
exclude group: 'javax.inject', module: 'javax.inject'
exclude group: 'javax.annotation', module: 'javax.annotation-api'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
androidTestCompile('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
exclude group: 'com.squareup.dagger', module: 'dagger'
exclude group: 'javax.inject', module: 'javax.inject'
exclude group: 'javax.annotation', module: 'javax.annotation-api'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.google.android.gms:play-services:+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.okio:okio:1.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
compile(name: 'gutenberg-sdk-release', ext: 'aar')
compile 'com.newrelic.agent.android:android-agent:4.244.0'
compile 'se.emilsjolander:stickylistheaders:2.5.2'
compile files('libs/crashlytics-1.1.11.jar')
compile files('libs/sugar-1.3.jar')
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
compile files('libs/zip4j_1.3.2.jar')
compile files('libs/joda-time-2.3.jar')
compile files('libs/android-query.0.26.7.jar')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
}
不知道为什么会造成这种情况。我检查了gradle文件,清理并重建了project.i已经完成了类似于这个问题的stackoverflow问题。但是没有任何问题。帮帮我吧,伙计!
答案 0 :(得分:0)
支持v7与支持v4发生冲突,并且您还添加了两个不同版本的appcompat,尝试使用此依赖项
dependencies {
androidTestCompile('com.jakewharton.espresso:espresso:1.1-r3') {
exclude group: 'com.squareup.dagger', module: 'dagger'
exclude group: 'javax.inject', module: 'javax.inject'
exclude group: 'javax.annotation', module: 'javax.annotation-api'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
androidTestCompile('com.jakewharton.espresso:espresso-support-v4:1.1-r3') {
exclude group: 'com.squareup.dagger', module: 'dagger'
exclude group: 'javax.inject', module: 'javax.inject'
exclude group: 'javax.annotation', module: 'javax.annotation-api'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
compile fileTree(include: ['*.jar'], exclude: 'android-support-v4.jar', dir: 'libs')
compile 'com.google.android.gms:play-services:+'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.okio:okio:1.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.dagger:dagger:1.2.1'
compile(name: 'gutenberg-sdk-release', ext: 'aar')
compile 'com.newrelic.agent.android:android-agent:4.244.0'
compile 'se.emilsjolander:stickylistheaders:2.5.2'
compile files('libs/crashlytics-1.1.11.jar')
compile files('libs/sugar-1.3.jar')
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
compile files('libs/zip4j_1.3.2.jar')
compile files('libs/joda-time-2.3.jar')
compile files('libs/android-query.0.26.7.jar')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
}
答案 1 :(得分:0)
<强> 1。从您的路径打开'studio.exe.vmoptions',如下所示:
机器人工作室安装-位置\机器人工作室\ bin中
<强> 2。更改此内容:
-Xms128m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
-XX:+UseCompressedOops
第3。重启Android工作室。
希望它会有所帮助。