Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

android - Updating Play services from 8.1 to 8.3 with Proguard enabled

I tried to update play services to 8.3. Here's what I changed :

In the root gradle file :

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0-beta1'
    classpath 'com.google.gms:google-services:1.5.0-beta2'
}

And in the app gradle file :

compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services-base:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.google.android.gms:play-services-appinvite:8.3.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-appindexing:8.3.0'

It's building fine, but it crashes on launch with the following stack trace :

11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.measurement.AppMeasurementContentProvider" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/app.example.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/app.example.debug-1/lib/arm, /vendor/lib, /system/lib]]
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread.-wrap1(ActivityThread.java)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    11-06 17:30:17.460 2895-2895/app.example.debug E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

We have proguard enabled, and usually have about 50/55k methods in our built apk. But with this setup, we get 26k.

Our original configuration was

classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.4.0-beta3'

With all the play services dependencies with version 8.1.0

Any idea about what's going on there?

EDIT

Here's our proguard file :

# will keep line numbers and file name obfuscation
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

-optimizations !code/allocation/variable

-dontwarn javax.mail.**
-dontwarn javax.management.**
-dontwarn javax.rmi.**
-dontwarn javax.naming.**
-dontwarn javax.transaction.**
-dontwarn javax.persistence.**
-dontwarn java.lang.management.**
-dontwarn java.lang.instrument.**
-dontwarn org.slf4j.**
-dontwarn org.json.**

-keep class org.apache.**
-dontwarn org.apache.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**

-dontwarn org.springframework.**

-dontwarn sun.misc.Unsafe
-dontwarn com.google.gwt.**


# Allow obfuscation of android.support.v7.internal.view.menu.**
# to avoid problem on Samsung 4.2.2 devices with appcompat v21
# see https://code.google.com/p/android/issues/detail?id=78377
-keep class !android.support.v7.internal.view.menu.*MenuBuilder*, android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

# Configuration for Fabric Twitter Kit
# See: https://dev.twitter.com/twitter-kit/android/integrate

-dontwarn com.squareup.okhttp.**
-dontwarn com.google.appengine.api.urlfetch.**
-dontwarn rx.**
-dontwarn retrofit.**
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* *;
}


# For using GSON @Expose annotation
-keepattributes *Annotation*
-keepattributes EnclosingMethod


# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }


# Branch
-keep class com.google.android.gms.ads.identifier.** { *; }


# OkHttp
-dontwarn rx.**

-dontwarn okio.**

-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }

-dontwarn retrofit.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}


# LeakCanary
-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }
-dontwarn com.squareup.leakcanary.DisplayLeakService


#Intercom
-dontwarn intercom.**
-dontwarn io.intercom.**


#Eventbus
-keepclassmembers class ** {
    public void onEvent*(**);
}


-keep class com.google.appengine.api.datastore.Text { *; }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Update your

classpath 'com.google.gms:google-services:1.5.0-beta2'

to the just released

classpath 'com.google.gms:google-services:1.5.0'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...