我有多个dex文件的标准问题:
错误:将字节码转换为dex时出错:原因: com.android.dex.DexException:多个dex文件定义 LCOM /谷歌/机器人/克/ R $阵列;
我正在开发一个依赖于Google Play服务(版本:9.4.0)的aar库。运行proguard时没有问题,但是当我将此库添加到应用程序时会出现dex问题。
Proguard文件(基于Android-proguard):
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
-keep class **.R
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepattributes InnerClasses
-keep public class * {
public protected <fields>;
public protected <methods>;
}
-dontwarn android.support.**
-keep class android.support.annotation.Keep
-keep @android.support.annotation.Keep class * {*;}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
Maven pom:
...
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-wallet</artifactId>
<type>aar</type>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>6.0_r1</version>
</dependency>
...
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<release>true</release>
<sdk>
<platform>21</platform>
</sdk>
<proguard>
<skip>false</skip>
<config>
${project.basedir}/proguard-android-pay.cfg
</config>
</proguard>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
Gradle构建文件:
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.jakewharton:butterknife:7.0.0'
compile('problematic.library.sdk:library-with-google-play-services:1.4.0-SNAPSHOT') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'org.jetbrains', module: 'annotations'
}
}