Android Studio中建立transformClassesWithJarMergingForDebug错误 [英] Android Studio build transformClassesWithJarMergingForDebug error

查看:2071
本文介绍了Android Studio中建立transformClassesWithJarMergingForDebug错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个新的项目我已经重新构建问题与Android工作室。请跟随我做了什么,如果任何人有任何想法如何着手,不要讲!

我开始一个新的项目,选择抽屉式导航活动'作为我的初始启动点(可以是任何东西我猜)。
我立刻建立我的新空的应用程序和调试它的真实设备(一个承上启下9)。所有运行良好。

然后我增加了一个办公文件创建库我想用于创建XLSX文件,所以我添加下面一行到我的build.gradle的应用程序文件(依赖):

 编译org.apache.poi:POI-OOXML:3.13

我重新同步,并建立OK(秒之内)。然后,我尝试调试这个真实设备上,但它并没有编译(需要更长的10倍,尝试构建),我得到一个错误:


  

错误:执行失败的任务:应用程序:transformClassesWithDexForDebug。
  com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:过程'命令'C:\\ Program Files文件\\的Java \\ jdk1.8.0_25 \\斌\\ java.exe的''与非完零退出值1


我看这件事和每一个地方,我期待人们告诉其他人使用 multiDex 。我明白这适用,如果你超过了65K的方法。我想用POI库我很可能是超过了。寻找行动没有其他的替代课程后,我实现multiDex通过添加以下行到我的build.gradle的应用程序文件:

  multiDexEnabled真
编译com.android.support:multidex:1.0.1

和添加以下行到我的清单文件:

 的android:NAME =android.support.multidex.MultiDexApplication

我想我已经实现了multiDex确定。该应用程序构建好,但是当我尝试调试它,我遇到了这个错误(需要大约7秒到达这里):


  

错误:执行失败的任务:应用程序:transformClassesWithJarMergingForDebug。
  com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复项:组织/阿帕奇/的XMLBeans / XML /流/ Location.class


没有其他的文件被篡改。如果我从的build.gradle删除编译POI库行则一切正常。我把图书馆回来,它无法以同样的方式。
我试图找出如何告诉它忽略XMLBeans的重复库(再次定岗告诉codeRS这是需要做什么),但我不知道该怎么做,如果是这样的最好的办法就是前锋,我应该还是multiDex'ing?

这是我花了几天就和小康远得到这个,这是我第一次使用Android的工作室 - 从Eclipse中迁移了,因为我受够了不能够建立天我的应用程序没有很好的原因。

有人谁知道这一切手段......请帮助我!

修改:我已清理和放大器;重建项目,并还试图删除构建文件,但无济于事。


计划统计:

  Android的工作室1.5.1
打造#AI-141.2456560,建于2015年12月1日
JRE:1.8.0_25-B18 AMD64
JVM:Java的热点(TM)64位服务器VM由Oracle公司
摇篮版本:2.8
Android插件版本1.5.0


的build.gradle应用程序文件

 应用插件:'com.android.application安卓{
    compileSdkVersion 23
    buildToolsVersion23.0.2    defaultConfig {
        的applicationIDcom.kane.testproject
        15的minSdkVersion
        targetSdkVersion 23
        版本code 1
        的versionName1.0
        multiDexEnabled真
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
}依赖{
    编译文件树(导演:'库',包括:['的* .jar'])
    testCompile'的JUnit:JUnit的:4.12
    编译com.android.support:appcompat-v7:23.1.1
    编译com.android.support:design:23.1.1
    编译org.apache.poi:POI-OOXML:3.13
    编译com.android.support:multidex:1.0.1
}

'的Andr​​oidManifest.xml文件

 <?XML版本=1.0编码=UTF-8&GT?;
<表明包=com.kane.testproject
          的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <应用
        机器人:名字=android.support.multidex.MultiDexApplication
        机器人:allowBackup =真
        机器人:图标=@的mipmap / ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:supportsRtl =真
        机器人:主题=@风格/ AppTheme>
        <活动
            机器人:名字=。MainActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ AppTheme.NoActionBar>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>
< /清单>


解决方案

添加以下行的build.gradle(模块的应用程序)

  dexOptions {
        javaMaxHeapSize2克
    }

I have a build problem with Android Studio in a new project I've recreated. Please follow what I've done and if anyone has any idea how to proceed, do tell!

I started a new project, selecting 'Navigation Drawer Activity' as my initial start-point (could be anything I guess). I instantly built my new 'empty' app and debugged it on a real device (a nexus 9). All runs fine.

I then added an office-file-creating library I want to use for creating xlsx files, so I added the following line to my build.gradle app file (in dependencies):

compile 'org.apache.poi:poi-ooxml:3.13'

I resync and it builds ok (within seconds). I then attempt to debug this on a real device but it doesn't build anymore (takes 10x longer to attempt build) and I get an error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1

I looked this up and every place I look people are telling others to use "multiDex". I understand this applies if you are exceeding 65K methods. I guess with the POI library I might well be exceeding that. After finding no other alternative course of action I implemented multiDex by adding the following lines to my build.gradle app file:

multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'

and adding the following line to my Manifest file:

android:name="android.support.multidex.MultiDexApplication"

I assume I've implemented the multiDex ok. The app builds ok but when I attempt to debug it I am met with this error (takes about 7sec to get here):

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

No other files were tampered with. If I remove the compile POI library line from build.gradle then all is ok. I put the library back in, it fails in the same way. I've tried to figure out how to tell it to ignore the duplicate library in xmlbeans (again other posts tell coders this is what needs to be done) but I'm not sure how to do that and if that is the best way forwards ie should I still be multiDex'ing?

It's taken me a few days on-and-off to get this far and it's my first time using Android Studio - migrating away from Eclipse because I'm fed up of not being able to build my apps for days for no good reason.

Someone who knows what this all means... help me please!

Edit: I have cleaned & rebuilt the project and also tried deleting the build files but to no avail.


Program stats:

Android Studio 1.5.1
Build #AI-141.2456560, built on December 1, 2015
JRE: 1.8.0_25-b18 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Gradle ver: 2.8
Android plugin ver 1.5.0


'build.gradle' app file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.kane.testproject"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'org.apache.poi:poi-ooxml:3.13'
    compile 'com.android.support:multidex:1.0.1'
}

'AndroidManifest.xml' file

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.kane.testproject"
          xmlns:android="http://schemas.android.com/apk/res/android">
    <application
        android:name="android.support.multidex.MultiDexApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

解决方案

Add the following lines in build.gradle(Module app)

dexOptions {
        javaMaxHeapSize "2g"
    }

这篇关于Android Studio中建立transformClassesWithJarMergingForDebug错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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