我有我在使用 AAR 文件的主要 android 项目中使用的库项目。我现在得到了我所期望的著名的 65k 方法限制,但我几乎没有什么疑问。
我在主项目的 libs 文件夹中添加了 AAR 文件,并在 build.gradle 中编译了相同的文件。
1) 我是否需要在库和主 android 项目中添加多 dex 支持?
2)我需要在两个项目中添加 afterEvaluate 脚本吗?
最重要的是,如果我们让多 dex 工作,我们可能会在主 android 项目中遇到 Classnotfound 异常,如果我们尝试使用的任何类不在主 dex 列表中。
编辑:-我正在尝试根据我的测试继续发布更新,以便任何有任何想法的人都可以帮助我们所有人。
项目中使用的依赖项:-
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'co.pointwise:pw-proto:0.0.5'
compile 'com.amazonaws:aws-android-sdk-sns:2.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.1'
compile 'com.github.tony19:logback-android-core:1.1.1-4'
compile 'com.github.tony19:logback-android-classic:1.1.1-4'
compile 'org.slf4j:slf4j-api:1.7.6'
compile 'com.android.support:multidex:1.0.0'
compile(name: 'sdk-debug', ext: 'aar') // my library project
// Crashlytics Kit
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true
}
}
17-08-2015 - 根据文档,我修改了我的代码及其现在的工作,但我无法使用 proguard 生成签名的 apk。
Proguard 文件看起来像:-
-keep class ch.qos.** { *; }
-keep class org.slf4j.** { *; }
-keep class io.protostuff.** { *; }
-keep class com.google.common.** { *; }
-keep com.amazonaws.http.** { *; }
-keep com.amazonaws.internal.** { *; }
-keepattributes *Annotation*
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
# Keep the names of classes/members we need for client functionality.
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
错误:-
Warning: com.amazonaws.AmazonWebServiceClient: can't find referenced class org.apache.commons.logging.LogFactory
Warning: ch.qos.logback.core.net.SMTPAppenderBase: can't find referenced class javax.mail.internet.MimeMessage
Warning: com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable
Warning: there were 1406 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 9 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
:app:proguardProdRelease FAILED
我之前也遇到过这个问题,在上一个项目中我无法解决它,但这次我需要解决它。
有任何想法吗?