Próbuję zalogować się za pomocą Facebooka za pomocą biblioteki ParseFacebookUtils i działa dobrze, ale po włączeniu pliku Proguard mam ten wyjątek na Facebooku Uruchomienie działalności:NullPointerExcepetion Facebook sdk v4.5.0 po włączeniu opcji Proguard (przy próbie zalogowania się przy użyciu biblioteki Parse)
plikFatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name/com.facebook.FacebookActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at java.lang.Enum$1.create(Enum.java:43)
at java.lang.Enum$1.create(Enum.java:35)
at libcore.util.BasicLruCache.get(BasicLruCache.java:54)
at java.lang.Enum.getSharedConstants(Enum.java:209)
at java.lang.Enum.valueOf(Enum.java:189)
at com.facebook.login.LoginBehavior.valueOf(LoginBehavior.java:26)
at com.facebook.login.LoginClient$Request.(LoginClient.java)
at com.facebook.login.LoginClient$Request.(LoginClient.java)
at com.facebook.login.LoginClient$Request$1.createFromParcel(LoginClient.java:2521)
at android.os.Parcel.readParcelable(Parcel.java:2111)
at android.os.Parcel.readValue(Parcel.java:2020)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getString(Bundle.java:1118)
at android.content.Intent.getStringExtra(Intent.java:5145)
at com.google.android.gms.analytics.Tracker$zza.zziJ(Unknown Source:4000)
at com.google.android.gms.analytics.GoogleAnalytics.isInitialized(Unknown Source)
at com.google.android.gms.analytics.GoogleAnalytics$zzb.onActivityStarted(Unknown Source)
at android.app.Application.dispatchActivityStarted(Application.java:219)
at android.app.Activity.onStart(Activity.java:1087)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:535)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1177)
at android.app.Activity.performStart(Activity.java:5461)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2386)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(NativeStart.java)
My Proguard:
-keep class !android.support.v7.internal.view.menu.**,android.support.v7.** {*;}
# -keep interface android.support.v7.** { *; }
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
# Keep source file names, line numbers, and Parse class/method names for easier debugging
-keepattributes SourceFile,LineNumberTable
-keepnames class com.parse.** { *; }
# Required for Parse
-keepattributes *Annotation*
-keepattributes Signature
-dontwarn android.net.SSLCertificateSocketFactory
-dontwarn android.app.Notification
-dontwarn com.squareup.**
-dontwarn okio.**
# Required for crashlytics
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-dontwarn android.support.v4.**
# Required for eventbus
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keepclassmembers class ** {
public void onEvent*(**);
}
Mój plik manifestu:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<provider android:authorities="com.facebook.app.FacebookContentProviderMyAppID"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
012 Kod
Login:
ParseFacebookUtils.logInWithReadPermissionsInBackground(this,
Collections.singletonList("public_profile"),
new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
if (user == null) {
mErrorMessage = ParseErrorHandler.handleParseError(err);
showContent(true);
} else if (user.isNew()) {
syncData();
} else {
syncData();
}
}
});
Uwaga: Aplikacja działa normalnie, gdy ustawiony minifyEnabled false
, więc mój problem z PROGUARD File
i wiem, że "Android dokumentacja Facebook SDK":
don Muszą wykonać dodatkowe kroki, aby użyć ProGuard dla zestawu SDK Facebooka Android Android .
Lista twoi Gradle zależności – AndyRoid
FYI, analizować jest zamknięcie do końca tego roku (2016), może warto o tym pamiętać – Ujju
@Ujju Tak wiem, że Dziękuję :). –