默认
发表评论 4
想开发IM:买成品怕坑?租第3方怕贵?找开源自已撸?尽量别走弯路了... 找站长给点建议
[已解决] Android Studio编译RainbowChat4a_pro_v4.3_b20180808(AS3.1工程)失败问题
AGPBI: {"kind":"error","text":"Program type already present: android.support.annotation.AnimRes","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\0.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\1.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\2.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\3.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\4.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\5.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\6.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\7.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\8.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\9.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\10.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\11.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\12.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\13.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\14.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\15.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\16.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\17.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\18.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\19.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\20.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\21.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\22.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\23.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\24.jar, E:\mobilesdk\RainbowChat\workspace\android\RainbowChat4a\app\build\intermediates\transforms\dexBuilder\debug\25.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 50s


gradle compileDebug --stacktrace  日志如下—————————————————————————————————————————————

FAILURE: Build failed with an exception.

* What went wrong:
Task 'compileDebug' is ambiguous in root project 'RainbowChat4a'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebugAndroidTestJa
vaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestShaders', 'compileDebugAndroidTestSources', 'compile
DebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugShaders', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compile
DebugUnitTestSources'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in root project 'RainbowChat4a'. Candidates are: 'compileDebugAidl', 'compileDebu
gAndroidTestAidl', 'compileDebugAndroidTestJavaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestShaders
', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'compileDebugRenderscript', 'compileDebugShaders', 'compileDebugSources',
'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources'.


网上搜索解决方案,尝试过使用multidex
使用较低版本Gradle,
删除jar包
重新导入项目,均无法解决
求助。。。


即时通讯网 - 即时通讯开发者社区! 来源: - 即时通讯开发者社区!

标签:RainbowChat

微信截图_20180829215229.png (122.91 KB, 下载次数: 707)

微信截图_20180829215229.png
上一篇:[已回复] RainbowChat的语音信息是像微信的一样就几乎是立即送到的机制吗?下一篇:[已回复] 求助RainbowChat部署成功后,发送消息,服务端可收到,接收方无反应
推荐方案
评论 4
这种问题应该就是Android studio的开环境没有弄好。android的开发工具配置是最闹心的,各种问题从来不重样。

从RainbowChat工程来说,为了追求简单,它没有任何一个jar包需要通过gradle下载(全部已经把使用到的jar放到Libs里了),工程的复杂度跟一个hello word差不多。

所以,我建议你这样来排查:
1)你把你的as删除掉,重新下载,比如我用的版本如下图所示:
[已解决] Android Studio编译RainbowChat4a_pro_v4.3_b20180808(AS3.1工程)失败问题_屏幕快照-2018-08-29-23.48.jpg

2)你重新配置好AS环境后,随便在网上找一个最简单的andorid hello word工程,把它跑起来,然后告诉我!

3)第2)步完成后,你再来尝试来跑RainbowChat工程(注意:解压后,不需要任何额外配置,直接用AS open这个工程即可!)

注意:第2)步很关键,如果你的AS环境连一个hello word都跑不通,那就连试都不要试,直到跑通一个hello word。相对来说,AS太复杂了,必须要保证它能正常跑起一个工程后,再引看RainbowChat。

你跑通第2)步后,截图并回复一下本贴!
非常感谢JackJiang的耐心指导,问题已解决
原因如下:
1.Android studio3.0后,compile依赖关系已被弃用,被implementation和api替代
implementation:只能在内部使用此模块,比如我在一个libiary中使用implementation依赖了gson库,然后我的主项目依赖了libiary,那么,我的主项目就无法访问gson库中的方法。这样的好处是编译速度会加快,推荐使用implementation的方式去依赖,如果你需要提供给外部访问,那么就使用api依赖即可2.由于在被依赖项目中, implementation files('libs/android-support-v4.jar'),
jar包是以implementation方式依赖的,在第一次编译 的时候会报:android.support.v4.content不存在
在Dependencies中添加v4包后,由于v4包冲突,报错:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 3.解决方式:删除自己添加的v4包;修改 被依赖项目中的jar包implementation为api;
dependencies {
    api files('libs/android-support-v4.jar')
    api files('libs/android-support-v7-recyclerview.jar')
    //compile files('libs/android-support-v7-appcompat.jar')
   
    //compile fileTree(include: ['*.jar'], dir: 'libs')
//    compile 'com.android.support:appcompat-v7:23.4.0'
//    compile 'com.android.support:recyclerview-v7:23.4.0'
}

微信图片_20180830105945.png (142.22 KB, 下载次数: 699)

微信图片_20180830105945.png
也有可能是AS版本的问题,我的版本如图:

微信图片_20180830111609.png (50.83 KB, 下载次数: 731)

微信图片_20180830111609.png
引用:smile 发表于 2018-08-30 11:16
也有可能是AS版本的问题,我的版本如图:

我的AS版本是v3.1确没有任何问题,你的也才v3.1.4,版本就差这么一点。。。其它客户也没有遇到这样的问题,相必也是用的跟我差不多的版本。

AS确实逗逼。。。
打赏楼主 ×
使用微信打赏! 使用支付宝打赏!

返回顶部