ionic 项目提示:

com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;

打开文件夹 build/intermediates/pre-dexed/debug:可以看到有两个android-suport-v4
Android Studio Multiple dex android/support/v4 处理_v9

方法一

1.首先通过依赖找到来源:
在项目内命令行运行:

gradle -q dependencies
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

2.然后使用exclude
“`
dependencies {
compile(‘com.commonsware.cwac:camera-v9:0.5.4’) {
exclude module: ‘support-v4-23.4.0’
}

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

}
“`

方法二、安装gradle view插件

在Settings-Plugins-Browse Repositories输入 gradle view

Android Studio Multiple dex android/support/v4 处理_v9_02
安装后重启android studio。
在android studio 界面中点击菜单view - Tool Window -Gradle View,开启Gradle View, Gradle View 插件会自动分析当前项目的依赖,分析完成后会形成一个报告。