From 9747caa4358ae32e164912cae83aa2378ad97387 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Fri, 4 Dec 2015 19:15:05 -0700 Subject: [PATCH] Fix Android ProGuard View rules & release signing - Enable ProGuard for the test app so the most common use case may be tested. - Update ProGuard to keep all Mapbox views and their methods. Previously, ProGuard was stripping numerous class methods including UserLocationView.g/setAccuracy(). These particular methods are accessed via reflection. On newer APIs, this manifests only in Logcat and loss of functionality: PropertyValuesHolder W Method setAccuracy() with type float not found on target class class com.mapbox.mapboxsdk.views.UserLocationView W Method getAccuracy() with type null not found on target class class com.mapbox.mapboxsdk.views.UserLocationView On Android 4.03 and 4.04 (API 15), this causes an NPE: java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:513) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:385) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:537) at android.animation.ValueAnimator.start(ValueAnimator.java:927) at android.animation.ValueAnimator.start(ValueAnimator.java:950) at android.animation.ObjectAnimator.start(ObjectAnimator.java:363) at com.mapbox.mapboxsdk.views.UserLocationView.setLocation(UserLocationView.java:401) at com.mapbox.mapboxsdk.views.UserLocationView.toggleGps(UserLocationView.java:300) at com.mapbox.mapboxsdk.views.UserLocationView.setEnabled(UserLocationView.java:230) at com.mapbox.mapboxsdk.views.MapView.setMyLocationEnabled(MapView.java:3122) ... Also add Support libraries rules to the test. Further amendments may be made by examining usage.txt[0,1]. [0] http://developer.android.com/tools/help/proguard.html#enabling [1] http://proguard.sourceforge.net/manual/usage.html#shrinkingoptions --- android/MapboxGLAndroidSDK/proguard-rules.pro | 7 +------ android/MapboxGLAndroidSDKTestApp/build.gradle | 2 +- android/MapboxGLAndroidSDKTestApp/proguard-rules.pro | 4 +++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/android/MapboxGLAndroidSDK/proguard-rules.pro b/android/MapboxGLAndroidSDK/proguard-rules.pro index 6853f3dde..c805eee19 100644 --- a/android/MapboxGLAndroidSDK/proguard-rules.pro +++ b/android/MapboxGLAndroidSDK/proguard-rules.pro @@ -16,9 +16,4 @@ -keep class com.mapbox.mapboxsdk.http.** { *; } # Package views --keep class com.mapbox.mapboxsdk.views.MapView** --keep class com.mapbox.mapboxsdk.views.NativeMapView** --keepclassmembers class com.mapbox.mapboxsdk.views.NativeMapView** { - *; -} - +-keep class com.mapbox.mapboxsdk.views.** { *; } diff --git a/android/MapboxGLAndroidSDKTestApp/build.gradle b/android/MapboxGLAndroidSDKTestApp/build.gradle index bdb483721..54b7a3b1d 100644 --- a/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -69,7 +69,7 @@ android { buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro b/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro index 578d94692..43a408f33 100644 --- a/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro +++ b/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro @@ -1 +1,3 @@ -# Proguard configuration is handeld in the SDK \ No newline at end of file +# Mapbox ProGuard configuration is handled in the SDK + +-keep class android.support.** { *; } \ No newline at end of file