当我在 Xerces 库中导入时,我似乎无法构建我的应用程序.由于以前的问题,我已经在使用 multidex,因此我知道这一切都正确设置.
我现在花了几天时间在网上寻找并尝试了各种版本的 Xerces 和对我的 build.gradle 的调整,但无法解决问题.我试过清理重建,重新设置Android Studio/我的电脑,使用jar直接编译,现在正式没有想法了.
下面是我的 build.gradle 设置:
<代码>android {compileSdkVersion 23构建工具版本23.0.2"默认配置 {应用程序ID#packageid#"minSdkVersion 18targetSdkVersion 23版本代码 1版本名称0.8"multiDexEnabled 真}构建类型 {调试{缩小启用假proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}发布 {缩小启用真proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}依赖{//编译 fileTree(include: ['*.jar'], dir: 'libs')测试编译'junit:junit:4.12'编译'com.android.support:multidex:1.0.1'编译'com.google.android.gms:play-services:8.4.0'编译'com.android.support:appcompat-v7:23.1.1'编译'com.android.support:support-v4:23.1.1'编译'com.android.support:design:23.1.1'编译'me.dm7.barcodescanner:zbar:1.8.4'编译项目(':rangebar-1.3')编译('com.crashlytics.sdk.android:crashlytics:2.5.5@aar'){传递=真;}编译'com.batch.android:batch-sdk:1.5'编译'xerces:xercesImpl:2.11.0'//编译文件('libs/xercesImpl-2.9.1.jar')}
我也已经扩展了我的应用程序,因此在课堂上使用了以下内容:
@Override受保护的无效 attachBaseContext(上下文基础){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: Process 'command 'C:Program FilesJavajdk1.7.0_79injava.exe'' 以非零退出值 1 结束
以下是我的 gradle 构建错误日志的结尾部分:
读取程序jar [C:DocumentsMobileProjectsIAAndroidappuildintermediates ransformsjarMergingdebugjars11fcombined.jar]读取库 jar [C:AppDataLocalAndroidsdkuild-tools23.0.2libshrinkedAndroid.jar]准备输出 jar [C:DocumentsMobileProjectsIAAndroidappuildintermediatesmulti-dexdebugcomponentClasses.jar]从程序 jar 复制资源 [C:DocumentsMobileProjectsIAAndroidappuildintermediates ransformsjarMergingdebugjars11fcombined.jar]:app:transformClassesWithMultidexlistForDebug 失败FAILURE:构建失败并出现异常.* 什么地方出了错:任务 ':app:transformClassesWithMultidexlistForDebug' 执行失败.>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.7.0_79injava.exe'' 以非零退出值 1 结束* 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪.使用 --info 或 --debug 选项运行以获得更多日志输出.构建失败
你试过清理rebuild,reset Android Studio/my PC,直接用jar编译,现在给你一些建议.希望对你有帮助.
在给出建议之前,我想告诉你先阅读这篇文章:配置你的带有 Gradle 的 Multidex 应用程序.然后您可以按照建议进行操作.
对于gradle bulid,必须遵循
<块引用> dev 利用 minSDKVersion = 21 来允许 Android gradle 插件对每个模块进行 pre-dex 并生成一个可以在其上进行测试的 APKAndroid Lollipop 无需耗时的 dex 合并过程.
您已将 minSdkVersion 用作 "minSdkVersion 18"
.所以请更新它.
注意:使用 Android Plugin for Gradle 版本低于 1.1,您需要为 multidex-instrumentation 添加以下依赖项:
依赖项{androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {排除组:'com.android.support',模块:'multidex'}}
注意:目前不支持使用 multidex 创建测试 APK.
您的输入 jar 包含多个同名的资源文件.ProGuard 像往常一样继续复制资源文件,跳过任何以前使用过的名称的文件.再一次,警告可能表明存在一些问题,因此建议删除重复项.一种方便的方法是在输入 jar 上指定过滤器.没有关闭这些警告的选项.
<块引用>标准的 Android 构建过程会自动指定输入给你的罐子.可能没有简单的方法来过滤它们以删除这些警告.您可以手动删除重复的资源文件来自输入和库.
ProGuard 可能会在遇到解析错误或 I/O 错误,或者一些更严重的警告时终止:
内存问题.我的 Messages Gradle Build 中有类似的消息
错误:任务 ':app:dexDebug' 执行失败.
<块引用>com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_45injava.exe'' 完成非零退出值 1我在装有 Windows 8.1 操作系统的笔记本电脑上没有可用 RAM.我关闭了一些我不需要的程序.在那之后,我有了更多的空闲内存,我的项目是在 android studio 中构建的.
有人建议关闭 Android Studio 并杀死 Java 进程,这非常大(1.2 GB).然后你可以用 gradle 运行.有帮助.
安装最新版本的构建工具.调整你的 build.gradle
以使用
`buildToolsVersion "22.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 FilesJavajdk1.7.0_79injava.exe'' finished with non-zero exit value 1
Below is the end part of my gradle build error log:
Reading program jar [C:DocumentsMobileProjectsIAAndroidappuildintermediates ransformsjarMergingdebugjars11fcombined.jar]
Reading library jar [C:AppDataLocalAndroidsdkuild-tools23.0.2libshrinkedAndroid.jar]
Preparing output jar [C:DocumentsMobileProjectsIAAndroidappuildintermediatesmulti-dexdebugcomponentClasses.jar]
Copying resources from program jar [C:DocumentsMobileProjectsIAAndroidappuildintermediates ransformsjarMergingdebugjars11fcombined.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 FilesJavajdk1.7.0_79injava.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
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.
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.
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.
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:
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 FilesJavajdk1.8.0_45injava.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.
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.
Install the latest version of the build tools. Adjust your build.gradle
to use
`buildToolsVersion "22.0.1"`
It helps some cases.
这篇关于导入 Xerces 库时无法构建应用程序(退出值 1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!