I have library project which I am using in main android project using AAR file. I am getting the famous 65k method limit now which I have expected, but I have few queries.
I have added AAR file in libs folder of my main project and compiled the same in build.gradle.
1) Do I need to add multi-dex support in both library as well as main android project?
2) Do I need to add afterEvaluate script in both project?
Most importantly if we got multi-dex working, we might get issue that in main android project we get Classnotfound exception if any of the class which we try to use is not in main dex list.
Edits :- I am trying to keep posting updates based on my testing so anyone who has any idea can help all of us.
dependencies used in project :-
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 - As per the documentation I modified my code and its working now, but I am unable to generate signed apk with proguard.
Proguard file looks like :-
-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;
}
Errors :-
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
I have faced the issue earlier as well, and i was not able to resolve it in last project but this time i need to solve it.
Any ideas?