多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

时间:2022-09-03 22:31:07

If I run gradle assembleDebug from the command line, I am suddenly getting this error:

如果我从命令行运行gradle assembleDebug,我将突然得到这个错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
    at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
    at com.android.dx.command.dexer.Main.run(Main.java:232)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)

If I grep for v4 I see two files inside my build folder.

如果我对v4进行grep,我将在构建文件夹中看到两个文件。

Binary file build/pre-dexed/debug/support-v4-19.0.0-2ba5fdd60a6c3836b3104a863fe42897da1fa9d1.jar matches
Binary file build/pre-dexed/debug/support-v4-r7-227d905d79b23b20866531d4f700446c040a2ccb.jar matches

My gradle file includes only this support library:

我的gradle文件只包括这个支持库:

compile 'com.android.support:support-v13:19.0.0'

I am stumped as to how the r7 library is included somehow. I've run gradle clean and it always appears there when I rerun assembleDebug.

我被难住了r7图书馆是怎么被包括进来的。我已经运行了gradle clean,当我重新运行组装调试时,它总是出现在那里。

If I grep for r7 inside the build directory, I see it inside the file:

如果我在构建目录中为r7 grep,我在文件中看到它:

Binary file build/exploded-bundles/ComGoogleAndroidGmsPlayServices4030.aar/classes.jar matches

If I don't include v13, then other things don't compile.

如果我不包括v13,那么其他的东西就不会编译。

But doesn't v13 include v4 support library?

但是v13不包括v4支持库吗?

Is this an incompatibility between play services AAR bundle and the v13 library?

这是游戏服务AAR bundle和v13库之间的不兼容性吗?

I grabbed the gradle file from gradleplease.appspot.com.

我从gradleplease.appspot.com获得了gradle文件。

Removing play services does not fix it; same error.

删除游戏服务并不能解决问题;同样的错误。

My dependencies inside build.gradle:

我的依赖性在build.gradle:

 dependencies {


 // Google Play Services
//compile 'com.google.android.gms:play-services:4.0.30'

// Support Libraries
//compile 'com.android.support:support-v4:19.0.0'
///compile 'com.android.support:appcompat-v7:19.0.0'
//compile 'com.android.support:gridlayout-v7:19.0.0'
compile 'com.android.support:support-v13:19.0.0'
compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
compile 'commons-codec:commons-codec:1.9'
compile 'com.madgag:markdownj-core:0.4.1'
compile 'com.wu-man:android-oauth-client:0.0.2'
compile 'com.google.http-client:google-http-client-jackson2:1.17.0-rc'
compile 'org.apache.commons:commons-lang3:3.2'
compile 'com.google.code.gson:gson:2.2.4'
}

24 个解决方案

#1


282  

Run gradle -q dependencies (or gradle -q :projectName:dependencies) to generate a dependency report. You should see where r7 is coming from, such as:

运行gradle -q依赖项(或gradle -q:projectName:dependencies)生成依赖报告。您应该看到r7的来源,例如:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    |    \--- com.google.android:support-v4:r7
|    +--- com.commonsware.cwac:camera:0.5.4
|    \--- com.android.support:support-v4:18.0.+ -> 18.0.0
\--- com.android.support:support-v4:18.0.+ -> 18.0.0

Then, use the exclude directive to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:

然后,使用排除指令来阻塞该依赖项。在我的例子中,它来自于我的CWAC-Camera库,所以我使用:

dependencies {
    compile('com.commonsware.cwac:camera-v9:0.5.4') {
      exclude module: 'support-v4'
    }

    compile 'com.android.support:support-v4:18.0.+'
}

(where the second compile statement indicates what version you actually want)

(第二个编译语句表示您实际需要的版本)

That should clear matters up, as you will see if you run the dependency report again:

这应该会很清楚,因为您将看到如果您再次运行依赖项报告:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    \--- com.commonsware.cwac:camera:0.5.4
\--- com.android.support:support-v4:18.0.+ -> 18.0.0

#2


114  

I solved similar error by adding following piece of code to my build.gradle file inside the android block.

我通过在构建中添加以下代码来解决类似的错误。android模块内的gradle文件。

android {
    dexOptions {
        preDexLibraries = false
    }
}

#3


33  

Also to note you can see your android dependencies, by going to your Android Studio Gradle view, and selecting the target "androidDependencies".

还要注意,你可以通过android Studio Gradle视图来查看android依赖项,并选择目标“androidDependencies”。

One more tip: I was having this issue, until I removed the v4 support lib from the libs folder in both the project and my related module/library project(s).

还有一个提示:在我从libs文件夹中删除了v4支持lib之后,我就有了这个问题,我的相关模块/库项目(s)。

#4


24  

Since A picture is worth a thousand words

一幅画胜过千言万语。

To make it easier and faster to get this task done with beginners like me. this is the screenshots that shows the answer posted by @edsappfactory.com that worked for me:

为了让像我这样的初学者完成这项任务变得更加容易和快捷。这是由@edsappfactory.com为我提供的答案的截图:

First open the Gradle view on the right side of Androidstudio:

首先打开Androidstudio右侧的Gradle视图:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Second you will see something like this :

第二,你会看到这样的东西:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

The main reason i posted this that it was not easy to know where to execute a gradle task or the commands posted above. So this is where to excute them as well.

我发布这篇文章的主要原因是,不容易知道在哪里执行一个分级任务或上面发布的命令。所以,这也是让他们变得可爱的地方。

SO, to execute gradle command:

因此,执行gradle命令:

First:

第一:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Second:

第二:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Easy as it is.

很容易。

Thats it.

这是它。

Thank you.

谢谢你!

#5


9  

In case anyone finds out that the answer from CommonsWare could not be applied to android library project, here is the snippet to fix

如果有人发现来自CommonsWare的答案不能应用到android library项目,那么下面的代码片段就可以解决了。

compile (project(':yourAndroidLibrary')){ exclude module: 'support-v13' }

编译(项目(':yourAndroidLibrary')){排除模块:'support-v13'}

You will find problems

你会发现问题

Unsupported Gradle DSL method found: 'exclude()'

不支持的Gradle DSL方法发现:“排除()”

if you use compile project(':yourAndroidLibrary'){ exclude module: 'support-v13' }

如果您使用compile项目(':yourAndroidLibrary'){排除模块:'support-v13'}

The differences are the bracelet "(" and ")" before "project".

不同之处是在“项目”之前的手链“(”和“)”。

#6


8  

I had the same problem and it seems that my app had too many methods because of the libraries: http://developer.android.com/tools/building/multidex.html

我遇到了同样的问题,我的应用程序似乎有太多的方法,因为这些库:http://developer.android.com/tools/building/multidex.html。

Solved it with:

解决了这个问题:

android {
   defaultConfig {
   ...
   multiDexEnabled = true
   }
}

More here Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2

更多的错误:执行失败的任务':app:dexDebug'。> comcommand以非零退出值2结束。

#7


7  

exclude module: 'support-v4'

Would not work for me with a project dependency, the only way I could get it to work was via the following syntax:

对于一个项目依赖项,我不会为我工作,我唯一能让它工作的方法是通过以下语法:

configurations {
    dependencies {
        compile(project(':Android-SDK')) {
            compile.exclude module: 'support-v4'
        }
    }
}

Where :Android-SDK is your project name.

其中:Android-SDK是您的项目名称。

#8


6  

I started getting this error when upgrading to ButterKnife 8.5.1. None of the other answers here worked for me.

升级到ButterKnife 8.5.1时,我开始犯这个错误。这里的其他答案都不适合我。

I used gradle -q :app:dependencies to see the tree, and then looked through jar files until I found the conflict. The conflict was that butterknife's dependency on com.android.support:support-compat:25.1.0 contains a version of the accessibility class, and com.android.support:support-v4:23.1.1 also contains the class.

我使用了gradle -q:app:依赖关系来查看树,然后查看jar文件,直到找到冲突为止。支持:support-compat:25.1.0包含一个可访问类的版本,以及com.android.support:support-v4:23.1.1还包含类。

I solved it by changing my dependency from this:

我通过改变依赖关系来解决这个问题:

compile 'com.jakewharton:butterknife:8.5.1'

to this:

:

compile('com.jakewharton:butterknife:8.5.1') {
    exclude module: 'support-compat'
}

It doesn't seem to affect ButterKnife's operation so far.

到目前为止,这似乎并没有影响到ButterKnife的操作。

Edit: There is a better solution, which was to upgrade my android support libraries to match ButterKnife's:

编辑:有一个更好的解决方案,就是升级我的android支持库来匹配ButterKnife的:

compile('com.android.support:appcompat-v7:25.2.0')
compile('com.android.support:design:25.2.0')
compile 'com.jakewharton:butterknife:8.5.1'

#9


5  

I had this same error but it was because I had recently changed from using v4 to v13. So all I had to do was clean the project.

我有同样的错误,但这是因为我最近从使用v4变成了v13。所以我要做的就是清理这个项目。

#10


5  

I had the same error on a legacy project. My fault was that the support-library was included twice: Once inside google-play-services lib, and another as standalone.

我在遗留项目上有相同的错误。我的错误是支持库包含了两次:一次是在google-play-service lib中,另一次是独立的。

This is how I fixed it:

我就是这样修正的:

BAD build.gradle:

坏build.gradle:

dependencies {
   compile files('libs/android-support-v4.jar') 
   compile files('libs/core-2.2.jar')
   compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
   compile 'com.google.android.gms:play-services:3.2.65'
}

GOOD build.gradle:

好build.gradle:

dependencies {
   // compile files('libs/android-support-v4.jar')  // not needed 
   compile files('libs/core-2.2.jar')
   compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
   compile 'com.google.android.gms:play-services:3.2.65'
}

Hope it helps someone :-)

希望它能帮助别人:-)

#11


3  

In my case the problem was caused by version inconsistency:

在我的案例中,问题是由版本不一致引起的:

Build tools 25
compileSdk 24
targetSdk 24
Support library 24

The solution was simple: Make everything version 25

解决方法很简单:让所有的版本都变成25。

#12


3  

A similar dex issue resolved method

一个类似的dex问题解决方法。

gradle.build was containing:

gradle。构建包含:

compile files('libs/httpclient-4.2.1.jar')
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

The issue was resolved when i removed

我移走后,问题就解决了。

compile files('libs/httpclient-4.2.1.jar') 

My gradle now looks like:

我现在的等级是:

apply plugin: 'com.android.application'

android {

compileSdkVersion 24
buildToolsVersion "24.0.3"

defaultConfig {
    applicationId "com.mmm.ll"
    minSdkVersion 16
    targetSdkVersion 24
    useLibrary  'org.apache.http.legacy'
}

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

dependencies {

compile 'com.google.android.gms:play-services:6.1.+'
compile files('libs/PayPalAndroidSDK.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar')
compile files('libs/picasso-2.1.1.jar')
compile files('libs/gcm.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}

There was a redundancy in the JAR file and the compiled gradle project

JAR文件和已编译的gradle项目有冗余。

So keenly look for dependency and jar files having same classes.

如此强烈地寻找具有相同类的依赖项和jar文件。

And remove redundancy.
This worked for me.

并去除冗余。这为我工作。

#13


2  

If you have imported your project from Eclipse.

如果您已经从Eclipse导入了您的项目。

1. The select project 
2. Go to File -> **Project Structure**
3. Select app in **module** section on left hand panel
4. Select **Dependency** tab
5. Your able to see jars you have added in eclipse project for v4 and v13.
6. Remove that jar by clicking on minus sign at bottom after selection
7. Click on Plus sign select **Library Dependency** 
8. Choose V4 and V13 if added
9. Press Ok and Clean and Rebuild your project

The scenario I have faced after importing Eclipse project to Android studio.

在向Android studio导入Eclipse项目之后,我遇到了这样的场景。

Hope this helps..

希望这可以帮助. .

#14


2  

I'm using com.google.android.gms:play-services-analytics:8.3.0 and android-support-v13.jar and could not get exclude module: 'support-v4' to work.

我正在使用com.google.android.gms:play-service -analytics:8.3.0和android- supportv13。jar和不能排除模块:“supportv4”工作。

What worked for me was using the android-support-v13 artefact rather than the android-support-v13.jar file.

我的工作是使用android-support-v13 artefact,而不是android-support-v13。jar文件。

I.e. instead of

例如,而不是

dependencies {
compile ('com.google.android.gms:play-services-analytics:8.3.0')
compile files('libs/android-support-v13.jar')

}

}

I used

我使用

dependencies {
compile ('com.google.android.gms:play-services-analytics:8.3.0')
compile ('com.google.android:android-support-v13')

}

}

#15


2  

This is an annoying problem, that can take some time to find out the root case. The way you should proceed is @CommonsWare answer.

这是一个恼人的问题,需要花些时间来找出根源。您应该进行的方式是@CommonsWare回答。

I faced this problem recently and found it hard to resolve.

我最近遇到了这个问题,觉得很难解决。

My problem was i was including a library by "+" version in build.gradle. Latest version of library contained one of older dex and bang.

我的问题是,我在build.gradle中加入了一个“+”版本的库。最新版本的库包含了一个旧的dex和bang。

I reverted to older version of library and solved it.

我恢复了旧版本的库并解决了它。

It is good to run your androidDependencies and see what is really happening. Its also good to search in your build folder.

运行您的androidDependencies并查看到底发生了什么是很好的。在构建文件夹中搜索也很好。

Above all Android Studio 2.2 provide in build features to track this problem.

首先,Android Studio 2.2提供了构建功能来跟踪这个问题。

Happy Coding Guys

快乐的编码向量

#16


2  

In Android Studio, go to your build.gradle (check both project and modules build.gradle files) and search for duplicate dependencies.

在Android Studio中,转到你的构建。gradle(检查项目和模块构建。并搜索重复的依赖项。

Delete those your project does not need.

删除项目不需要的内容。

#17


1  

I removed compile 'com.android.support:support-v4:18.0.+' in dependencies, and it works

我删除编译com.android.support:support-v4:18.0。在依赖关系中,它起作用。

#18


1  

Deleting all files from Gradle cache fixed my problem.

从Gradle缓存中删除所有文件修复了我的问题。

on Linux:

在Linux上:

cd ~/.gradle  
rm -R -f *

#19


0  

Finally, I solved it modifiying these attributes on the module gradle file

最后,我解决了在模块gradle文件中修改这些属性。

  1. compileSdkVersion 25
  2. compileSdkVersion 25
  3. targetSdkVersion 25
  4. targetSdkVersion 25
  5. compile 'com.android.support:appcompat-v7:+'
  6. 编译的com.android.support:appcompat-v7:+
  7. compile 'com.android.support:recyclerview-v7:+'
  8. 编译的com.android.support:recyclerview-v7:+

#20


0  

I had the same problem when adding react-native-palette to my project, here is my dependencies tree:

我在我的项目中添加了“反应-原生-调色板”时遇到了同样的问题,这里是我的依赖树:

./gradlew app:dependencies
+--- project :react-native-palette
|    +--- com.facebook.react:react-native:0.20.+ -> 0.44.2
|    |    +--- javax.inject:javax.inject:1
|    |    +--- com.android.support:appcompat-v7:23.0.1
|    |    |    \--- com.android.support:support-v4:23.0.1
|    |    |         \--- com.android.support:support-annotations:23.0.1 -> 24.2.1
...
|    \--- com.android.support:palette-v7:24.+ -> 24.2.1
|         +--- com.android.support:support-compat:24.2.1
|         |    \--- com.android.support:support-annotations:24.2.1
|         \--- com.android.support:support-core-utils:24.2.1
|              \--- com.android.support:support-compat:24.2.1 (*)
+--- com.android.support:appcompat-v7:23.0.1 (*)
\--- com.facebook.react:react-native:+ -> 0.44.2 (*)

I tried many solutons and could not fix it, until changing the com.android.support:appcompat version in android/app/build.gradle, I wish this can help:

我尝试了许多解决方案,但无法修复它,直到改变了com.android。支持:appcompat android / app /构建版本。gradle,我希望这能有所帮助:

dependencies {
    compile project(':react-native-palette')
    compile project(':react-native-image-picker')
    compile project(':react-native-camera')
    compile fileTree(dir: "libs", include: ["*.jar"])
    // compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.android.support:appcompat-v7:24.2.1"
    compile "com.facebook.react:react-native:+"
}

it seems that multiple entries is not a big problem, version mismatch is

似乎多个条目不是一个大问题,版本不匹配是。

#21


0  

Got it working for a compile file('...') conflict by increasing minSdkVersion to 21 and enabling multidex. Not sure if that is the best solution but the only way I could get it working in my case.

通过将minSdkVersion增加到21并启用multidex,将其用于编译文件('…')冲突。我不确定这是否是最好的解决方案,但我能让它在我的案例中发挥作用的唯一方法。

Note: for compile file('...') it appears that you cannot put in an exclude clause so that option was not available.

注意:对于编译文件('…'),似乎您不能放入一个排除子句,这样选项就不可用。

#22


0  

I had the same problem, and my solution is changing the support version '27.+'(27.1.0) to '27.0.1'

我遇到了同样的问题,我的解决方案是将支持版本的“27.+”(27.1)改为“27.0.1”。

#23


0  

I've had the same issue. In my project, I had the following dependencies :

我也遇到过同样的问题。在我的项目中,我有以下依赖项:

  • appcompat-v7
  • appcompat-v7
  • android-support-v13
  • android-support-v13

For legacy reasons, the appcompat was fetched from the Google Maven repo, whereas the android-support was a local .jar.

由于遗留原因,appcompat是从谷歌Maven repo获取的,而android支持是本地的.jar。

When I figured out this, and replaced this local reference with a maven reference, it just solved my build issue.

当我发现这一点,并用maven引用替换这个本地引用时,它就解决了我的构建问题。

Here's the diff of my app/build.gradle :

这是我的应用程序的diff。gradle:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

#24


0  

I resolved all of my issues by adding this into project.properties

我通过将这个添加到project.properties中来解决所有的问题。

cordova.system.library.7=com.android.support:appcompat-v7:27.1.0

#1


282  

Run gradle -q dependencies (or gradle -q :projectName:dependencies) to generate a dependency report. You should see where r7 is coming from, such as:

运行gradle -q依赖项(或gradle -q:projectName:dependencies)生成依赖报告。您应该看到r7的来源,例如:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    |    \--- com.google.android:support-v4:r7
|    +--- com.commonsware.cwac:camera:0.5.4
|    \--- com.android.support:support-v4:18.0.+ -> 18.0.0
\--- com.android.support:support-v4:18.0.+ -> 18.0.0

Then, use the exclude directive to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:

然后,使用排除指令来阻塞该依赖项。在我的例子中,它来自于我的CWAC-Camera库,所以我使用:

dependencies {
    compile('com.commonsware.cwac:camera-v9:0.5.4') {
      exclude module: 'support-v4'
    }

    compile 'com.android.support:support-v4:18.0.+'
}

(where the second compile statement indicates what version you actually want)

(第二个编译语句表示您实际需要的版本)

That should clear matters up, as you will see if you run the dependency report again:

这应该会很清楚,因为您将看到如果您再次运行依赖项报告:

compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
|    +--- com.actionbarsherlock:actionbarsherlock:4.4.0
|    \--- com.commonsware.cwac:camera:0.5.4
\--- com.android.support:support-v4:18.0.+ -> 18.0.0

#2


114  

I solved similar error by adding following piece of code to my build.gradle file inside the android block.

我通过在构建中添加以下代码来解决类似的错误。android模块内的gradle文件。

android {
    dexOptions {
        preDexLibraries = false
    }
}

#3


33  

Also to note you can see your android dependencies, by going to your Android Studio Gradle view, and selecting the target "androidDependencies".

还要注意,你可以通过android Studio Gradle视图来查看android依赖项,并选择目标“androidDependencies”。

One more tip: I was having this issue, until I removed the v4 support lib from the libs folder in both the project and my related module/library project(s).

还有一个提示:在我从libs文件夹中删除了v4支持lib之后,我就有了这个问题,我的相关模块/库项目(s)。

#4


24  

Since A picture is worth a thousand words

一幅画胜过千言万语。

To make it easier and faster to get this task done with beginners like me. this is the screenshots that shows the answer posted by @edsappfactory.com that worked for me:

为了让像我这样的初学者完成这项任务变得更加容易和快捷。这是由@edsappfactory.com为我提供的答案的截图:

First open the Gradle view on the right side of Androidstudio:

首先打开Androidstudio右侧的Gradle视图:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Second you will see something like this :

第二,你会看到这样的东西:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

The main reason i posted this that it was not easy to know where to execute a gradle task or the commands posted above. So this is where to excute them as well.

我发布这篇文章的主要原因是,不容易知道在哪里执行一个分级任务或上面发布的命令。所以,这也是让他们变得可爱的地方。

SO, to execute gradle command:

因此,执行gradle命令:

First:

第一:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Second:

第二:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

Easy as it is.

很容易。

Thats it.

这是它。

Thank you.

谢谢你!

#5


9  

In case anyone finds out that the answer from CommonsWare could not be applied to android library project, here is the snippet to fix

如果有人发现来自CommonsWare的答案不能应用到android library项目,那么下面的代码片段就可以解决了。

compile (project(':yourAndroidLibrary')){ exclude module: 'support-v13' }

编译(项目(':yourAndroidLibrary')){排除模块:'support-v13'}

You will find problems

你会发现问题

Unsupported Gradle DSL method found: 'exclude()'

不支持的Gradle DSL方法发现:“排除()”

if you use compile project(':yourAndroidLibrary'){ exclude module: 'support-v13' }

如果您使用compile项目(':yourAndroidLibrary'){排除模块:'support-v13'}

The differences are the bracelet "(" and ")" before "project".

不同之处是在“项目”之前的手链“(”和“)”。

#6


8  

I had the same problem and it seems that my app had too many methods because of the libraries: http://developer.android.com/tools/building/multidex.html

我遇到了同样的问题,我的应用程序似乎有太多的方法,因为这些库:http://developer.android.com/tools/building/multidex.html。

Solved it with:

解决了这个问题:

android {
   defaultConfig {
   ...
   multiDexEnabled = true
   }
}

More here Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2

更多的错误:执行失败的任务':app:dexDebug'。> comcommand以非零退出值2结束。

#7


7  

exclude module: 'support-v4'

Would not work for me with a project dependency, the only way I could get it to work was via the following syntax:

对于一个项目依赖项,我不会为我工作,我唯一能让它工作的方法是通过以下语法:

configurations {
    dependencies {
        compile(project(':Android-SDK')) {
            compile.exclude module: 'support-v4'
        }
    }
}

Where :Android-SDK is your project name.

其中:Android-SDK是您的项目名称。

#8


6  

I started getting this error when upgrading to ButterKnife 8.5.1. None of the other answers here worked for me.

升级到ButterKnife 8.5.1时,我开始犯这个错误。这里的其他答案都不适合我。

I used gradle -q :app:dependencies to see the tree, and then looked through jar files until I found the conflict. The conflict was that butterknife's dependency on com.android.support:support-compat:25.1.0 contains a version of the accessibility class, and com.android.support:support-v4:23.1.1 also contains the class.

我使用了gradle -q:app:依赖关系来查看树,然后查看jar文件,直到找到冲突为止。支持:support-compat:25.1.0包含一个可访问类的版本,以及com.android.support:support-v4:23.1.1还包含类。

I solved it by changing my dependency from this:

我通过改变依赖关系来解决这个问题:

compile 'com.jakewharton:butterknife:8.5.1'

to this:

:

compile('com.jakewharton:butterknife:8.5.1') {
    exclude module: 'support-compat'
}

It doesn't seem to affect ButterKnife's operation so far.

到目前为止,这似乎并没有影响到ButterKnife的操作。

Edit: There is a better solution, which was to upgrade my android support libraries to match ButterKnife's:

编辑:有一个更好的解决方案,就是升级我的android支持库来匹配ButterKnife的:

compile('com.android.support:appcompat-v7:25.2.0')
compile('com.android.support:design:25.2.0')
compile 'com.jakewharton:butterknife:8.5.1'

#9


5  

I had this same error but it was because I had recently changed from using v4 to v13. So all I had to do was clean the project.

我有同样的错误,但这是因为我最近从使用v4变成了v13。所以我要做的就是清理这个项目。

#10


5  

I had the same error on a legacy project. My fault was that the support-library was included twice: Once inside google-play-services lib, and another as standalone.

我在遗留项目上有相同的错误。我的错误是支持库包含了两次:一次是在google-play-service lib中,另一次是独立的。

This is how I fixed it:

我就是这样修正的:

BAD build.gradle:

坏build.gradle:

dependencies {
   compile files('libs/android-support-v4.jar') 
   compile files('libs/core-2.2.jar')
   compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
   compile 'com.google.android.gms:play-services:3.2.65'
}

GOOD build.gradle:

好build.gradle:

dependencies {
   // compile files('libs/android-support-v4.jar')  // not needed 
   compile files('libs/core-2.2.jar')
   compile files('libs/universal-image-loader-1.8.5-with-sources.jar')
   compile 'com.google.android.gms:play-services:3.2.65'
}

Hope it helps someone :-)

希望它能帮助别人:-)

#11


3  

In my case the problem was caused by version inconsistency:

在我的案例中,问题是由版本不一致引起的:

Build tools 25
compileSdk 24
targetSdk 24
Support library 24

The solution was simple: Make everything version 25

解决方法很简单:让所有的版本都变成25。

#12


3  

A similar dex issue resolved method

一个类似的dex问题解决方法。

gradle.build was containing:

gradle。构建包含:

compile files('libs/httpclient-4.2.1.jar')
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

The issue was resolved when i removed

我移走后,问题就解决了。

compile files('libs/httpclient-4.2.1.jar') 

My gradle now looks like:

我现在的等级是:

apply plugin: 'com.android.application'

android {

compileSdkVersion 24
buildToolsVersion "24.0.3"

defaultConfig {
    applicationId "com.mmm.ll"
    minSdkVersion 16
    targetSdkVersion 24
    useLibrary  'org.apache.http.legacy'
}

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

dependencies {

compile 'com.google.android.gms:play-services:6.1.+'
compile files('libs/PayPalAndroidSDK.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar')
compile files('libs/picasso-2.1.1.jar')
compile files('libs/gcm.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
}

There was a redundancy in the JAR file and the compiled gradle project

JAR文件和已编译的gradle项目有冗余。

So keenly look for dependency and jar files having same classes.

如此强烈地寻找具有相同类的依赖项和jar文件。

And remove redundancy.
This worked for me.

并去除冗余。这为我工作。

#13


2  

If you have imported your project from Eclipse.

如果您已经从Eclipse导入了您的项目。

1. The select project 
2. Go to File -> **Project Structure**
3. Select app in **module** section on left hand panel
4. Select **Dependency** tab
5. Your able to see jars you have added in eclipse project for v4 and v13.
6. Remove that jar by clicking on minus sign at bottom after selection
7. Click on Plus sign select **Library Dependency** 
8. Choose V4 and V13 if added
9. Press Ok and Clean and Rebuild your project

The scenario I have faced after importing Eclipse project to Android studio.

在向Android studio导入Eclipse项目之后,我遇到了这样的场景。

Hope this helps..

希望这可以帮助. .

#14


2  

I'm using com.google.android.gms:play-services-analytics:8.3.0 and android-support-v13.jar and could not get exclude module: 'support-v4' to work.

我正在使用com.google.android.gms:play-service -analytics:8.3.0和android- supportv13。jar和不能排除模块:“supportv4”工作。

What worked for me was using the android-support-v13 artefact rather than the android-support-v13.jar file.

我的工作是使用android-support-v13 artefact,而不是android-support-v13。jar文件。

I.e. instead of

例如,而不是

dependencies {
compile ('com.google.android.gms:play-services-analytics:8.3.0')
compile files('libs/android-support-v13.jar')

}

}

I used

我使用

dependencies {
compile ('com.google.android.gms:play-services-analytics:8.3.0')
compile ('com.google.android:android-support-v13')

}

}

#15


2  

This is an annoying problem, that can take some time to find out the root case. The way you should proceed is @CommonsWare answer.

这是一个恼人的问题,需要花些时间来找出根源。您应该进行的方式是@CommonsWare回答。

I faced this problem recently and found it hard to resolve.

我最近遇到了这个问题,觉得很难解决。

My problem was i was including a library by "+" version in build.gradle. Latest version of library contained one of older dex and bang.

我的问题是,我在build.gradle中加入了一个“+”版本的库。最新版本的库包含了一个旧的dex和bang。

I reverted to older version of library and solved it.

我恢复了旧版本的库并解决了它。

It is good to run your androidDependencies and see what is really happening. Its also good to search in your build folder.

运行您的androidDependencies并查看到底发生了什么是很好的。在构建文件夹中搜索也很好。

Above all Android Studio 2.2 provide in build features to track this problem.

首先,Android Studio 2.2提供了构建功能来跟踪这个问题。

Happy Coding Guys

快乐的编码向量

#16


2  

In Android Studio, go to your build.gradle (check both project and modules build.gradle files) and search for duplicate dependencies.

在Android Studio中,转到你的构建。gradle(检查项目和模块构建。并搜索重复的依赖项。

Delete those your project does not need.

删除项目不需要的内容。

#17


1  

I removed compile 'com.android.support:support-v4:18.0.+' in dependencies, and it works

我删除编译com.android.support:support-v4:18.0。在依赖关系中,它起作用。

#18


1  

Deleting all files from Gradle cache fixed my problem.

从Gradle缓存中删除所有文件修复了我的问题。

on Linux:

在Linux上:

cd ~/.gradle  
rm -R -f *

#19


0  

Finally, I solved it modifiying these attributes on the module gradle file

最后,我解决了在模块gradle文件中修改这些属性。

  1. compileSdkVersion 25
  2. compileSdkVersion 25
  3. targetSdkVersion 25
  4. targetSdkVersion 25
  5. compile 'com.android.support:appcompat-v7:+'
  6. 编译的com.android.support:appcompat-v7:+
  7. compile 'com.android.support:recyclerview-v7:+'
  8. 编译的com.android.support:recyclerview-v7:+

#20


0  

I had the same problem when adding react-native-palette to my project, here is my dependencies tree:

我在我的项目中添加了“反应-原生-调色板”时遇到了同样的问题,这里是我的依赖树:

./gradlew app:dependencies
+--- project :react-native-palette
|    +--- com.facebook.react:react-native:0.20.+ -> 0.44.2
|    |    +--- javax.inject:javax.inject:1
|    |    +--- com.android.support:appcompat-v7:23.0.1
|    |    |    \--- com.android.support:support-v4:23.0.1
|    |    |         \--- com.android.support:support-annotations:23.0.1 -> 24.2.1
...
|    \--- com.android.support:palette-v7:24.+ -> 24.2.1
|         +--- com.android.support:support-compat:24.2.1
|         |    \--- com.android.support:support-annotations:24.2.1
|         \--- com.android.support:support-core-utils:24.2.1
|              \--- com.android.support:support-compat:24.2.1 (*)
+--- com.android.support:appcompat-v7:23.0.1 (*)
\--- com.facebook.react:react-native:+ -> 0.44.2 (*)

I tried many solutons and could not fix it, until changing the com.android.support:appcompat version in android/app/build.gradle, I wish this can help:

我尝试了许多解决方案,但无法修复它,直到改变了com.android。支持:appcompat android / app /构建版本。gradle,我希望这能有所帮助:

dependencies {
    compile project(':react-native-palette')
    compile project(':react-native-image-picker')
    compile project(':react-native-camera')
    compile fileTree(dir: "libs", include: ["*.jar"])
    // compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.android.support:appcompat-v7:24.2.1"
    compile "com.facebook.react:react-native:+"
}

it seems that multiple entries is not a big problem, version mismatch is

似乎多个条目不是一个大问题,版本不匹配是。

#21


0  

Got it working for a compile file('...') conflict by increasing minSdkVersion to 21 and enabling multidex. Not sure if that is the best solution but the only way I could get it working in my case.

通过将minSdkVersion增加到21并启用multidex,将其用于编译文件('…')冲突。我不确定这是否是最好的解决方案,但我能让它在我的案例中发挥作用的唯一方法。

Note: for compile file('...') it appears that you cannot put in an exclude clause so that option was not available.

注意:对于编译文件('…'),似乎您不能放入一个排除子句,这样选项就不可用。

#22


0  

I had the same problem, and my solution is changing the support version '27.+'(27.1.0) to '27.0.1'

我遇到了同样的问题,我的解决方案是将支持版本的“27.+”(27.1)改为“27.0.1”。

#23


0  

I've had the same issue. In my project, I had the following dependencies :

我也遇到过同样的问题。在我的项目中,我有以下依赖项:

  • appcompat-v7
  • appcompat-v7
  • android-support-v13
  • android-support-v13

For legacy reasons, the appcompat was fetched from the Google Maven repo, whereas the android-support was a local .jar.

由于遗留原因,appcompat是从谷歌Maven repo获取的,而android支持是本地的.jar。

When I figured out this, and replaced this local reference with a maven reference, it just solved my build issue.

当我发现这一点,并用maven引用替换这个本地引用时,它就解决了我的构建问题。

Here's the diff of my app/build.gradle :

这是我的应用程序的diff。gradle:

多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat。

#24


0  

I resolved all of my issues by adding this into project.properties

我通过将这个添加到project.properties中来解决所有的问题。

cordova.system.library.7=com.android.support:appcompat-v7:27.1.0