I have an application that uses modification for api calls. I am trying to add a pro guard, but it continues to fail with one of the answers.
FATAL EXCEPTION: main Process: com.karriapps.smartsiddurlite, PID: 13387
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.List.get(int)' on a null object reference
at com.karriapps.smartsiddur.util.b$3.a(SourceFile:255)
at com.karriapps.smartsiddur.util.b$3.success(SourceFile:252)
at retrofit.CallbackRunnable$1.run(SourceFile:45)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5431)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
I know the answer contains data, it just cannot deserialize it
Here is the code that doesn't work
mElavationService.getElevation(new ElavationService.LatLng(mLocation.getLatitude(), mLocation.getLongitude()),
BING_KEY,
new Callback<BingElevationResponse>() {
@Override
public void success(BingElevationResponse bingElevationResponse, Response response) {
double elavation = bingElevationResponse.getResourceSets().get(0)
.getResources().get(0).getOffsets().get(0);
if (elavation > 0) {
mLocation.setElevation(elavation);
} else {
mLocation.setElevation(0);
}
responsesCount++;
if (requestsCount == responsesCount) {
setZmanimToLocation(mLocation);
}
}
@Override
public void failure(RetrofitError error) {
Log.e(TAG, error.toString(), error.fillInStackTrace());
mLocation.setElevation(0);
responsesCount++;
if (requestsCount == responsesCount) {
setZmanimToLocation(mLocation);
}
}
});
And my protector file
-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class *
-keepnames public class * extends io.realm.RealmObject
-dontwarn javax.**
-dontwarn io.realm.**
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile, LineNumberTable, *Annotation*
-keep public class * extends java.lang.Exception
-keep class com.android.vending.billing.**
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-dontwarn org.joda.convert.**
-dontwarn org.joda.time.**
-keep class org.joda.time.** { *; }
-keep interface org.joda.time.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class retrofit.** { *; }
-keep class retrofit.http.** { *; }
-keep class retrofit.client.** { *; }
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.**
-dontwarn rx.**
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
-keepattributes Exceptions
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-keep class android.support.v7.widget.RoundRectDrawable { *; }
-dontwarn com.mixpanel.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-keepattributes Signature
-keepattributes *Annotation*
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.karriapps.smartsiddur.model.response.** { *; }
-keepnames public class com.karriapps.smartsiddur.model.response.**
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
Edit: I added a pojo class
public class BingElevationResponse {
private List<ResourceSet> resourceSets;
public List<ResourceSet> getResourceSets() {
return resourceSets;
}
public class ResourceSet {
private List<Resource> resources;
public List<Resource> getResources() {
return resources;
}
}
public class Resource {
private List<Integer> elevations;
public List<Integer> getOffsets() {
return elevations;
}
}
}
This way
com.karriapps.smartsiddur.model.response.BingElevationResponse
I would really appreciate ant help
source
share