地图开发——腾讯地图混淆::app:shrinkReleaseMultiDexComponents

来源:互联网 发布:java写入txt文件 编辑:程序博客网 时间:2024/06/05 14:10

这些天在搞腾讯地图,当混淆的时候出现了一个问题:

Error:Execution failed for task ':app:shrinkReleaseMultiDexComponents'.> java.io.IOException: The output jar [E:\winjia\Android\AndroidHelperJump\app\build\intermediates\multi-dex\release\componentClasses.jar] must be specified after an input jar, or it will be empty.

出问题了,说是有多个Dex组建,但是在build.gradle中已经配置了multiDexEnabled=true,这是怎么回事呢。仔细看看最后一行解释:must be specified after an input jar, or it will be empty.应该是因为部分jar包没有引入,导致jar为空的问题。在来看看混淆的代码:

#Tencent map sdk-libraryjars libs/TencentLocationSDK_v5.0.1.jar-keep class com.tencent.**{*;}#腾讯地图 2D sdk-libraryjars libs/TencentMapSDK_Raster_v_1.2.6_160cf1b.jar-keep class com.tencent.mapsdk.**{*;}-keep class com.tencent.tencentmap.**{*;}#腾讯地图 3D sdk-libraryjars libs/TencentMapSDK_Raster_v_1.2.6_160cf1b.jar-keep class com.tencent.tencentmap.**{*;}-keep class com.tencent.map.**{*;}#腾讯地图检索sdk-libraryjars libs/TencentSearch1.1.3.jar-keep class com.tencent.lbssearch.**{*;}-keep class com.google.gson.examples.android.model.** { *; }#腾讯地图街景sdk#如果街景混淆报出类似"java.io.IOException: Can't read [*\TencentPanoramaSDKv1.1.0_15232.jar"#请参考http://bbs.map.qq.com/forum.php?mod=viewthread&tid=21098&extra=page=1&filter=typeid&typeid=95&typeid=95-libraryjars libs/TencentPanoramaSDK_v.1.2.0_16324.jar-keep class com.tencent.tencentmap.streetviewsdk.**{*;}

在我的项目里,并没有使用到街景sdk和3Dsdk,直接把这几个jar的混淆注释掉,然后再看看,然后添加以下混淆代码:

-keepclassmembers class ** {    public void on*Event(...);}-keepclasseswithmembernames class * {  native <methods>;}-dontwarn  org.eclipse.jdt.annotation.**-dontwarn android.location.Location-dontwarn ct.**-dontwarn com.tencent.**

官网论坛上说只有api 18以下的需要加这些代码,不知道为啥,不加的话,发布版本混淆会失败,加入这些代码之后,方可混淆成功。

0 0
原创粉丝点击