firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.64k stars 1.83k forks source link

Class not found when unmarshalling: com.firebase.ui.auth.ui.FlowParameters #926

Closed olealgoritme closed 6 years ago

olealgoritme commented 7 years ago

When using FirebaseUI Auth with Facebook, it crashes immediately after launching the Activity. The google-services.json file is updated.

The Facebook app ID is set in strings.xml:

<string name="facebook_application_id" translatable="false">appid</string>
<string name="facebook_login_protocol_scheme" translatable="false">fb_appid</string>

Have tried versions of google play services, facebook sdk, firebase, firebase ui, to no avail. When removing Facebook as provider, and only using Google Sign-in/Phone/Email, it works without any issues.

Problem persists in debug and release APK.

Any suggestions on whats going on?

 startActivityForResult(
                AuthUI.getInstance().createSignInIntentBuilder()
                        .setTheme(getTheme())
                        .setLogo(R.drawable.logo)
                        .setAvailableProviders(getProviders())
                        .setTosUrl(getTosUrl())
                        .setPrivacyPolicyUrl(getPrivacyPolicyUrl())
                        .setIsSmartLockEnabled(false)
                        .setAllowNewEmailAccounts(false)
                        .build(),
                RC_SIGN_IN);

Log output:

Class not found when unmarshalling: com.firebase.ui.auth.ui.FlowParameters
                                         java.lang.ClassNotFoundException: com.firebase.ui.auth.ui.FlowParameters
                                             at java.lang.Class.classForName(Native Method)
                                             at java.lang.Class.forName(Class.java:400)
                                             at android.os.Parcel.readParcelableCreator(Parcel.java:2517)
                                             at android.os.Parcel.readParcelable(Parcel.java:2471)
                                             at android.os.Parcel.readValue(Parcel.java:2374)
                                             at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
                                             at android.os.BaseBundle.unparcel(BaseBundle.java:269)
                                             at android.os.BaseBundle.getString(BaseBundle.java:992)
                                             at android.content.Intent.getStringExtra(Intent.java:6702)
                                             at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:336)
                                             at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1094)
                                             at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5836)
                                             at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5641)
                                             at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:176)
                                             at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3611)
                                             at android.os.Binder.execTransact(Binder.java:573)
                                          Caused by: java.lang.ClassNotFoundException: com.firebase.ui.auth.ui.FlowParameters
                                             at java.lang.Class.classForName(Native Method)
                                             at java.lang.BootClassLoader.findClass(ClassLoader.java:1346)
                                             at java.lang.BootClassLoader.loadClass(ClassLoader.java:1406)
                                             at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                             at java.lang.Class.classForName(Native Method) 
                                             at java.lang.Class.forName(Class.java:400) 
                                             at android.os.Parcel.readParcelableCreator(Parcel.java:2517) 
                                             at android.os.Parcel.readParcelable(Parcel.java:2471) 
                                             at android.os.Parcel.readValue(Parcel.java:2374) 
                                             at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) 
                                             at android.os.BaseBundle.unparcel(BaseBundle.java:269) 
                                             at android.os.BaseBundle.getString(BaseBundle.java:992) 
                                             at android.content.Intent.getStringExtra(Intent.java:6702) 
                                             at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:336) 
                                             at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1094) 
                                             at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5836) 
                                             at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5641) 
                                             at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:176) 
                                             at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3611) 
                                             at android.os.Binder.execTransact(Binder.java:573) 
                                          Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

======================================================

builde.gradle (app)

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.lemon.wave"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "auto" // FirebaseUI translations for all string resources
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.2'
            }
        }
    }
}

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
       //exclude group: 'com.google.android.gms'
        //exclude group: 'com.google.firebase'
    })

    testCompile 'junit:junit:4.12'

    // support libs
    compile 'com.android.support:design:26.0.2'
    compile 'com.android.support:support-v4:26.0.2'
    compile 'com.android.support:mediarouter-v7:26.0.2'
    compile 'com.android.support:support-v13:26.0.2'
    compile 'com.android.support:recyclerview-v7:26.0.2'
    compile 'com.android.support:cardview-v7:26.0.2'
    compile 'com.android.support:palette-v7:26.0.2'
    compile 'com.android.support:customtabs:26.0.2'
    compile 'com.android.support:support-fragment:26.0.2'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:multidex:1.0.1'

    // google play services
    compile 'com.google.android.gms:play-services-base:11.4.0'
    compile 'com.google.android.gms:play-services-auth:11.4.0'

    // firebase
    compile 'com.google.firebase:firebase-auth:11.4.0'
    compile 'com.google.firebase:firebase-database:11.4.0'
    compile 'com.google.firebase:firebase-core:11.4.0'
    compile 'com.google.firebase:firebase-storage:11.4.0'
    compile 'com.google.firebase:firebase-crash:11.4.0'
    compile 'com.google.firebase:firebase-messaging:11.4.0'

    // firebase ui
    compile 'com.firebaseui:firebase-ui-database:2.3.0'
    compile 'com.firebaseui:firebase-ui-auth:2.3.0'
    compile('com.facebook.android:facebook-android-sdk:4.22.1')

    // div
    compile 'com.squareup.okhttp3:okhttp:3.9.0'
    compile 'codelight.studios:android-smart-login:1.2'
    compile 'me.leolin:ShortcutBadger:1.1.18@aar'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.jakewharton:butterknife:8.8.1'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.afollestad:material-camera:0.4.4'
    compile 'com.afollestad:easyvideoplayer:0.3.0'
    compile 'com.cleveroad:audiovisualization:1.0.0'
    compile 'com.mikepenz:iconics-core:2.9.3@aar'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'com.mikepenz:fastadapter-commons:2.6.3@aar'
    compile 'com.mikepenz:itemanimators:1.0.0@aar'
    compile 'com.mikepenz:google-material-typeface:2.2.0.1@aar'
    compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    compile('com.mikepenz:materialdrawer:5.9.5@aar') {
        transitive = true
    }
    compile('com.mikepenz:aboutlibraries:5.9.5@aar') {
        transitive = true
        exclude module: "fastadapter"
    }
}
apply plugin: 'com.google.gms.google-services'

======================================================

build.gradle (Project)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.1'
        classpath 'com.google.firebase:firebase-plugins:1.1.1'

    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }

        maven { url "https://dl.bintray.com/drummer-aidan/maven" }

        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

======================================================

LeeHounshell commented 7 years ago

My app is having the same issue. I am able to solve the missing FlowParameters class by adding to my AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature" />

However, I still see this FirebaseUI and Facebook related problem in the logs:

09-28 00:46:58.577 2519-8255/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=user_engagement(_e),params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=9603, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=4654341430752817376}] 09-28 00:46:58.586 7991-8248/com.harlie.myapplication V/FA: Activity resumed, time: 4997508 09-28 00:46:58.587 2519-8255/com.google.android.gms V/FA-SVC: Saving event, name, data size: user_engagement(_e), 68 09-28 00:46:58.590 7991-8248/com.harlie.myapplication V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 10 09-28 00:46:58.591 7991-8248/com.harlie.myapplication V/FA: Activity paused, time: 4997510 09-28 00:46:58.592 2519-8255/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.harlie.myapplication', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=9603, firebase_screen_class(_sc)=LoginActivity, firebase_screen_id(_si)=4654341430752817376}]} 09-28 00:46:58.595 7991-7991/com.harlie.myapplication V/FA: onActivityCreated 09-28 00:46:58.600 7991-8248/com.harlie.myapplication D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=LoginActivity, firebase_previous_id(_pi)=4654341430752817376, firebase_screen_class(_sc)=KickoffActivity, firebase_screen_id(_si)=4654341430752817377}] 09-28 00:46:58.602 2519-8255/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 2252520 09-28 00:46:58.604 2519-8255/com.google.android.gms V/FA-SVC: Cancelling job. JobID: 812057698 09-28 00:46:58.604 2519-8255/com.google.android.gms V/FA-SVC: Scheduling upload with AlarmManager 09-28 00:46:58.604 2519-8255/com.google.android.gms V/FA-SVC: Background event processing time, ms: 27 09-28 00:46:58.631 7991-7991/com.harlie.myapplication D/AndroidRuntime: Shutting down VM

                                                                          --------- beginning of crash

09-28 00:46:58.632 7991-7991/com.harlie.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.harlie.myapplication, PID: 7991 java.lang.NoSuchMethodError: No static method setWebDialogTheme(I)V in class Lcom/facebook/FacebookSdk; or its super classes (declaration of 'com.facebook.FacebookSdk' appears in /data/app/com.harlie.myapplication-2/base.apk) at com.firebase.ui.auth.provider.FacebookProvider.(FacebookProvider.java:67) at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.populateIdpList(AuthMethodPickerActivity.java:108) at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onCreate(AuthMethodPickerActivity.java:81) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 09-28 00:46:58.636 2519-8255/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=LoginActivity, firebase_previous_id(_pi)=4654341430752817376, firebase_screen_class(_sc)=KickoffActivity, firebase_screen_id(_si)=4654341430752817377}] 09-28 00:46:58.639 2519-8255/com.google.android.gms V/FA-SVC: Saving event, name, data size: screen_view(_vs), 99 09-28 00:46:58.640 2519-8255/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.harlie.myapplication', name='screen_view(_vs)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=LoginActivity, firebase_previous_id(_pi)=4654341430752817376, firebase_screen_class(_sc)=KickoffActivity, firebase_screen_id(_si)=4654341430752817377}]} 09-28 00:46:58.644 2519-8255/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 2252474 09-28 00:46:58.645 1674-1686/system_process W/ActivityManager: Force finishing activity com.harlie.myapplication/com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity 09-28 00:46:58.648 1674-1686/system_process W/ActivityManager: Force finishing activity com.harlie.myapplication/com.firebase.ui.auth.KickoffActivity 09-28 00:46:58.651 2519-8255/com.google.android.gms V/FA-SVC: Cancelling job. JobID: 812057698 09-28 00:46:58.654 2519-8255/com.google.android.gms V/FA-SVC: Scheduling upload with AlarmManager

samtstern commented 7 years ago

@LeeHounshell you've been using FirebaseUI for a while, when did this issue start for you?

LeeHounshell commented 7 years ago

I just noticed this problem for the first time today. I am wondering if the FacebookSdk has changed?

My build.gradle has:

implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
SUPERCILEX commented 7 years ago

@LeeHounshell Oh yeah, using free flowing versioning is usually a bad idea exactly for this reason. Facebook just released v4.27 and it looks like

updates proguard files

is probably what's tripping us up.

For now, you can downgrade to v4.26 until we can sort this out. Thanks for the tip! 😄

LeeHounshell commented 7 years ago

I can confirm that downgrading to the old Facebook Sdk works. Use this in your build.gradle:

implementation 'com.facebook.android:facebook-android-sdk:4.26.0'

Thanks everybody!

samtstern commented 7 years ago

Here's the ProGuard from the Facebook SDKs:

4.27.0

-keepclassmembers class * implements java.io.Serializable {
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keepnames class com.facebook.FacebookActivity
-keepnames class com.facebook.CustomTabActivity

-keep class com.facebook.all.All

-keep public class com.android.vending.billing.IInAppBillingService {
    public static com.android.vending.billing.IInAppBillingService asInterface(android.os.IBinder);
    public android.os.Bundle getSkuDetails(int, java.lang.String, java.lang.String, android.os.Bundle);
}

4.26.0

-keepclassmembers class * implements java.io.Serializable {
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
SUPERCILEX commented 7 years ago

@samtstern Ok, so it actually has nothing to do with proguard. It turns out Facebook literally moved methods around in a minor release. Not cool Facebook! 👿😆 Anyway, see #929.

olealgoritme commented 7 years ago

For me, downgrading fbSdk or adding that weird permission didn't change anything. Still same

SUPERCILEX commented 7 years ago

@thailemon yeah, that's a separate issue. Somehow, your proguard config is stripping out firebase classes. Just to make sure, the crash only happens in release mode, right? If so, could you show me your proguard config?

olealgoritme commented 7 years ago

@SUPERCILEX no, it happens in both debug and release.

SUPERCILEX commented 7 years ago

@thailemon Hmmm, OK. That's weird. Try deleting the .gradle folder in your project's root directory and running a ./gradlew clean cleanBuildCache before running the app.

olealgoritme commented 7 years ago

@SUPERCILEX Yes, it's very weird indeed. clean/cleanBuildCache doesn't change anything either - not in debug nor release :/

samtstern commented 6 years ago

This issue is pretty old (x months) and I have not seen any additional reports, going to close it for now. @thailemon if you are still seeing this or if you fixed it please let us know! Happy to continue the discussion.