我在重新创建的项目中使用Android Studio时遇到了构建问题。请按照我所做的步骤,并告诉我如何继续,如果您有任何想法!
我开始一个新项目,并选择“导航抽屉活动”作为我的初始起点(可能是任何东西)。我立即构建了我的新的“空”应用程序,并在真实设备(Nexus 9)上进行了调试。一切正常运行。
然后,我添加了一个我想要用于创建xlsx文件的office-file-creating库,因此我在我的build.gradle app文件(依赖项中)中添加了以下行:
并添加以下行到我的清单文件中:
我假设我已经成功实现了multiDex。应用程序构建正常,但当我尝试调试时,遇到以下错误(大约需要7秒钟才能到达此处):
“Error: Execution failed for task ':app: transformClassesWithJarMergingForDebug'。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/xmlbeans/xml/stream/Location.class”
没有其他文件被篡改。如果我从build.gradle中删除编译POI库行,则一切正常。我把库放回去,它以相同的方式失败。 我试图弄清楚如何告诉它忽略xmlbeans中的重复库(其他帖子告诉编码人员这就是需要完成的工作),但我不确定如何做到这一点,而且这是否是最好的前进方式,即我是否仍然需要multiDex?
我已经花了几天时间断断续续地做到了这一点,这是我第一次使用Android Studio-迁移到Eclipse,因为我厌倦了无缘无故地不能为我的应用程序构建几天的情况。
知道这一切意义的人......请帮帮我!
编辑:我已清理并重建了项目,并尝试删除构建文件,但无济于事。
程序统计:
我开始一个新项目,并选择“导航抽屉活动”作为我的初始起点(可能是任何东西)。我立即构建了我的新的“空”应用程序,并在真实设备(Nexus 9)上进行了调试。一切正常运行。
然后,我添加了一个我想要用于创建xlsx文件的office-file-creating库,因此我在我的build.gradle app文件(依赖项中)中添加了以下行:
compile 'org.apache.poi:poi-ooxml:3.13'
我重新同步并且构建成功了(几秒钟内),然后我尝试在真实设备上调试,但是它不再构建了(构建尝试时间长了10倍),我得到了一个错误:
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
我查找了这个问题,每个地方的人都告诉其他人使用“multiDex”。我理解如果你超过了65K个方法,那么就需要这个。我猜测可能是由于POI库,我超过了这个限制。在找不到其他措施之后,我通过将以下行添加到我的build.gradle应用程序文件中来实现multiDex:
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
并添加以下行到我的清单文件中:
android:name="android.support.multidex.MultiDexApplication"
我假设我已经成功实现了multiDex。应用程序构建正常,但当我尝试调试时,遇到以下错误(大约需要7秒钟才能到达此处):
“Error: Execution failed for task ':app: transformClassesWithJarMergingForDebug'。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/xmlbeans/xml/stream/Location.class”
没有其他文件被篡改。如果我从build.gradle中删除编译POI库行,则一切正常。我把库放回去,它以相同的方式失败。 我试图弄清楚如何告诉它忽略xmlbeans中的重复库(其他帖子告诉编码人员这就是需要完成的工作),但我不确定如何做到这一点,而且这是否是最好的前进方式,即我是否仍然需要multiDex?
我已经花了几天时间断断续续地做到了这一点,这是我第一次使用Android Studio-迁移到Eclipse,因为我厌倦了无缘无故地不能为我的应用程序构建几天的情况。
知道这一切意义的人......请帮帮我!
编辑:我已清理并重建了项目,并尝试删除构建文件,但无济于事。
程序统计:
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' 应用程序文件
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'文件
<?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>