我可以integrate (add & work) with many libraries
.
但至于ActionBarSherlock
图书馆,我有很多问题.
第一期是热门问题Multiple dex files define
,
我知道duplicated android-support-v4.jar
它的原因,但我现在无法解决这个问题:
Error:Execution failed for task ':fitness:dexDebug'. Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)
我在同样的错误中遵循了答案.它用于:
dependencies { compile('...') { exclude module: 'support-v4' } compile 'com.android.support:support-v4:18.0.+' }
但我收到第二期:unsupported Gradle DSL method found: 'exclude()'!
错误.因此,我改变build.gradle
了main module
这样的:
//configurations { // all*.exclude group: 'com.android.support', module: 'support-v4' //} dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile project(':google-play-services') compile files('/google-play-services/libs/google-play-services.jar') compile (project(':actionbarsherlock')) { exclude(module: 'support-v4') } compile 'com.android.support:support-v4:18.0.+' }
Solved
第二期,但仍然得到第一期 Multiple dex files define
错误.
我读了很多主题,但现在无法解决第一期,
请帮我,
谢谢,
p/s:我可以顺利地与Gradle同步,但是在运行时,它会遇到错误.
我使用Android studio 0.5.5
编辑
build.gradle
的ActionBarSherlock
,它只有一个android-support-v4.jar
:
dependencies { compile fileTree(dir: 'libs', include: '*.jar') }
setting.gradle
像这样 :
include ':fitness', ':google-play-services',':actionbarsherlock'
@Garbriele:我更新了新的问题,显示build.gradle of project
及build.gradle of main module
build.gradle
的project
:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } }
build.gradle
的main module
修改后:
dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' // Get following error in this line }
我在下面得到了这个错误:
好的,感谢@Garbriele的评论,我已经通过使用这个解决了这个问题:
repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar' // Get following error in this line }
编辑2当我这样说:
repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.google.android.gms:play-services:+' }
仍然会收到First Issue Multiple dex files define
错误.
我现在想要的是如何成功添加com.google.android.gms:play-services
库Maven
,
请帮我,
谢谢,
UPDATE
完成以下步骤后:
将库通过Maven放入build.gradle
主模块中:compile 'com.google.android.gms:play-services:+'
Restart Android Studio
Sync project with gradle
再也不会出现此错误.