[英]Multiple dex files define in Android Studio
I know this is a common issue, but I've checked all other posts and none of them helped. 我知道这是一个常见的问题,但我检查了所有其他帖子,但没有一个帮助。 A lot of them are for eclipse, and the ones for android studio don't help. 其中很多都是用于eclipse,而android工作室则没有帮助。
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
What I've tried: 我尝试过的:
First, I get the bug that it is a repository but there is no git, so I just remove volley (that worked for my teammate). 首先,我得到的错误是它是一个存储库,但没有git,所以我只是删除了凌空(这对我的队友有用)。 Then, while all other 4 members get it to work, mine stalls and bugs there. 然后,当所有其他4名成员开始工作时,我的摊位和虫子就在那里。 There are also 4 warnings, one is below, the rest are similar: 还有4个警告,一个在下面,其余类似:
Warning:warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
If it helps, this is the gradle file below: 如果有帮助,这是下面的gradle文件:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/commons-logging-1.2.jar')
compile files('libs/com.fasterxml.jackson.databind.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/httpclient-4.5.1.jar')
compile files('libs/httpcore-4.4.3.jar')
compile files('libs/jackson-core-2.7.1.jar')
compile files('libs/sun.misc.BASE64Decoder.jar')
compile files('libs/jackson-annotations-2.7.1.jar')
compile files('libs/jackson-databind-2.7.1-1.jar')
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:gridlayout-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.csc301.team7.era"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
Removing two of the extra volley lines in gradle in turn gives me this error in gradle: 在gradle中删除两条额外的凌空线依次给我这个错误:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/fasterxml/jackson/databind/AbstractTypeResolver;
but I can't find AbstractTypeResolver. 但我找不到AbstractTypeResolver。
Please, any help getting this project to run would be greatly appreciated. 请非常感谢任何有助于此项目运行的帮助。
This error: 这个错误:
Ignoring InnerClasses attribute for an anonymous inner class
is an issue I had too. 我也是一个问题。 It is an issue related to inner classes when using Proguard. 使用Proguard时,这是与内部类相关的问题。 It can be solved by adding the following to your proguard file: 可以通过在proguard文件中添加以下内容来解决:
-keepattributes EnclosingMethod
-keepattributes InnerClasses
Proguard and inner classes often lead to issues. Proguard和内部课程经常导致问题。 By adding the lines above, you indicate to Proguard that it should keep inner classes where they are and not treat them as if they are in their own files. 通过添加上面的行,您向Proguard指出它应该保留内部类,而不是将它们视为它们在自己的文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.