Xerces - Android Studio gradle setup - 错误构建应用程序(退出值1) [英] Xerces - Android Studio gradle setup - error building app (exit value 1)

查看:640
本文介绍了Xerces - Android Studio gradle setup - 错误构建应用程序(退出值1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在xerces库中导入时,似乎无法让我的应用程序生成。由于之前的问题,我已经在使用multidex,因此我知道这些设置都是正确的。



我花了几天的时间在网上寻找并尝试各种版本的xerces和调整到我的build.gradle,但不能解决问题。我已经尝试清理重新构建,重新设置Android Studio /我的电脑,使用直接编译的jar,现在正式出来的想法。



以下是我的build.gradle setup:

  android {
compileSdkVersion 23
buildToolsVersion23.0.2

defaultConfig {
applicationId#packid#
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName0.8
multiDexEnabled true
}

uildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}

依赖关系{
//编译fileTree(包括:['* .jar'],dir:'libs')
testCompile'junit:junit:4.12'
compile'c​​om.android.support:multidex:1.0.1'
compile'c​​om.google .android.gms:play-services:8.4.0'
compile'c​​om.android.support:appcompat-v7:23.1.1'
compile'c​​om.android.support:support-v4:23.1 .1'
compile'c​​om.android.support:design:23.1.1'
compile'me.dm7.barcodescanner:zbar:1.8.4'
compile project(':rangebar- 1.3')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar'){
transitive = true;
}
编译'com.batch.android:batch-sdk:1.5'
编译'xerces:xercesImpl:2.11.0'
//编译文件('libs / xercesImpl -2.9.1.jar')
}

我也已经扩展了我的应用程序,因此在类中使用了以下内容:

  @Override 
protected void attachBaseContext(Context base){
super.attachBaseContext(base);

MultiDex.install(this);
}

但是,每次我尝试构建时,都会收到以下错误:

 错误:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。 
> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\程序文件\Java\jdk1 .7.0_79 \\\\\\\\\\\''''''用非零退出值1



编辑1 - 下面是我的gradle构建错误日志的结束部分:

 读取程序jar [ C:\Documents\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar] 
读取库jar [C:\AppData\Local\Android\sdk\build-tools\23.0.2\lib\shrinkedAndroid.jar]
准备输出jar [C:\ Documents \ MobileProjects \IA\Android\app\build\intermediates\multi-dex\debug\componentClasses.jar]
从程序jar复制资源[C:\Documen ts\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
:app: transformClassesWithMultidexlistForDebug FAILED

FAILURE:构建失败,出现异常。

*出错:
任务':app:transformClassesWithMultidexlistForDebug'的执行失败。
> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\程序文件\Java\jdk1 .7.0_79 \\\\\\\\\\\''''''用非零退出值1

结束Try:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。

BUILD FAILED

编辑2 - I已上传我目前使用的 Xerces测试项目,试图将库编译到我的项目中,请随时查看一下,以便进一步调试我可能错过的任何内容./解决方案

尝试清理重新构建,重新设置Android Studio /我的电脑,直接使用jar进行编译,现在我想给你一些建议。希望它能帮助你。



在给出建议之前,我想告诉你先阅读这篇文章:使用Gradle为您的应用程序配置Multidex 。然后你可以按照建议。

建议-1:



对于gradle bulid,必须遵循


  dev使用minSDKVersion = 21允许Android gradle插件
分别预先分类模块并生成一个可以在
Android Lollipop上测试的APK,而无需耗时的dex合并过程。


您已将minSdkVersion用作minSdkVersion 18\" 。所以请更新它。



建议-2:



注意:Android插件for Gradle版本低于1.1 ,您需要为multidex-instrumentation添加以下依赖项:

 依赖关系{
androidTestCompile('com.android。支持:multidex-instrumentation:1.0.1'){
exclude group:'com.android.support',module:'multidex'
}
}

注意:目前不支持使用multidex创建测试APK。



建议-3:



您的输入jar包含多个具有相同名称的资源文件。 ProGuard像往常一样继续复制资源文件,跳过具有以前使用名称的任何文件。再一次,警告可能是一些问题的迹象,所以建议删除重复项。一个方便的方法是在输入罐上指定过滤器。没有选择关闭这些警告。


标准Android构建过程自动为您指定输入
的罐子。可能没有简单的方法来过滤这些警告以删除
这些警告。您可以从输入和库中手动移除重复资源文件

ProGuard可能会在遇到解析错误时终止或I / O错误或一些更严重的警告:

建议-4:



问题RAM。我的消息Gradle Build中有类似的消息


$ b 错误:执行任务失败:app:dexDebug'。

< blockquote>

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\程序文件\Java\jdk1.8.0_45 \bin\java.exe''以非零退出值1
结束我的笔记本电脑上没有可用的RAM,操作系统Windows 8.1。我关闭了一些我不需要的程序。然后,我有更多的可用RAM,我的项目是在android studio中构建的。




建议-5:



有人建议关闭Android Studio并杀死非常大的Java进程(1.2 GB)。然后你可以用gradle运行。它有帮助。

建议-6:



安装最新版本的构建工具。调整您的 build.gradle 以使用

 `buildToolsVersion22.0.1 `

它有助于某些情况。


I cannot seem to get my app to build when I import in the xerces library. I am already using the multidex due to previous issues and therefore I know this is all setup properly.

I have spend a couple of days now looking online and trying all sorts of versions of xerces and tweaks to my build.gradle but cannot work out the issue. I have tried cleaning re-building, re-setting Android Studio/my PC, using a jar directly compiling and now officially out of ideas.

Below is my build.gradle setup:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "#packageid#"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "0.8"
        multiDexEnabled true
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
//    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'me.dm7.barcodescanner:zbar:1.8.4'
    compile project(':rangebar-1.3')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile 'com.batch.android:batch-sdk:1.5'
    compile 'xerces:xercesImpl:2.11.0'
//    compile files('libs/xercesImpl-2.9.1.jar')
}

I have also extended my Application already and therefore have used the following within the class:

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);

    MultiDex.install(this);
}

However, every time I try to build I keep getting the following error:

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: 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

EDIT 1 - Below is the end part of my gradle build error log:

Reading program jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
Reading library jar [C:\AppData\Local\Android\sdk\build-tools\23.0.2\lib\shrinkedAndroid.jar]
Preparing output jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\multi-dex\debug\componentClasses.jar]
  Copying resources from program jar [C:\Documents\MobileProjects\IA\Android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
:app:transformClassesWithMultidexlistForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: 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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

EDIT 2 - I have uploaded the Xerces test project I am currently using in an attempt to get the library compiled into my project, please feel free to have a look in an effort to further debug anything that I may have missed./

解决方案

As you have tried cleaning re-building, re-setting Android Studio/my PC, using a jar directly for compiling, now I want to give you some suggestions. Hope it can help you.

Before giving suggestion, I want to tell you to go through this article first: Configuring Your App for Multidex with Gradle. Then you can follow the suggestions.

Suggestion-1:

For gradle bulid, it must be followed

         dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
         to pre-dex each module and produce an APK that can be tested on
         Android Lollipop without time consuming dex merging processes.

You have used minSdkVersion as "minSdkVersion 18". So plase update it.

Suggestion-2:

Note: With Android Plugin for Gradle versions lower than 1.1, you need to add the following dependency for multidex-instrumentation:

dependencies {
    androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {
         exclude group: 'com.android.support', module: 'multidex'
    }
}

Note: Use of multidex for creating a test APK is not currently supported.

Suggestion-3:

Your input jars contain multiple resource files with the same name. ProGuard continues copying the resource files as usual, skipping any files with previously used names. Once more, the warning may be an indication of some problem though, so it's advisable to remove the duplicates. A convenient way to do so is by specifying filters on the input jars. There is no option to switch off these warnings.

The standard Android build process automatically specifies the input jars for you. There may not be an easy way to filter them to remove these warnings. You could remove the duplicate resource files manually from the input and the libraries.

ProGuard may terminate when it encounters parsing errors or I/O errors, or some more serious warnings:

Suggestion-4:

Problem RAM. I had similar message in my Messages Gradle Build

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1 I didn't have free RAM on my laptop with the OS windows 8.1. I closed a few programs that I don't need. After that, I had more free RAM and my project was built in android studio.

Suggestion-5:

Some people suggested to close Android Studio and kill the java processs, which was very big (1.2 GB). Then you can run with gradle. It helps.

Suggestion-6:

Install the latest version of the build tools. Adjust your build.gradle to use

`buildToolsVersion "22.0.1"`

It helps some cases.

这篇关于Xerces - Android Studio gradle setup - 错误构建应用程序(退出值1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆