大家好我已经浏览了stackoverflow中的所有ans但仍未解决我的问题。 这是我的gradle文件(app)。没有complile time error但是当我运行项目时出现错误。
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.android.animationsdemo"
minSdkVersion 14
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.+'
}
错误: -
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
答案 0 :(得分:0)
将 defaultConfig 替换为 defaultConfig
,只需添加multiDexEnabled true
defaultConfig {
applicationId 'com.example.android.animationsdemo'
minSdkVersion 14
targetSdkVersion 17
multiDexEnabled true
}
答案 1 :(得分:0)
将此代码放入您的gradle中。
defaultConfig {
multiDexEnabled = true
}
答案 2 :(得分:0)
在构建gradle中启用multidex。它应该位于构建gradle中,包含包名,版本名,代码等,而不在外部.gradle文件中。
添加
multiDexEnabled = true
在defaultConfig中