firebase auth plugin - demo on android gives me a black screen. init() does not work

Dear Corona community,

I just purchased the firebase auth plugin from Scott and am currently struggling a lot on how to implement just a simple demo. I downloaded the demo-project from here:

https://github.com/scottrules44/firebaseAuth-demo

and also downloaded the google-services.json file from firebase-console.

When I try to run it on an Android device, I get the following error:

"Runtime Error:

…main.lua:7: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzeku"

========

/edit: Changing config.lua solves that problem.

New problem: Now I just get a black screen when init() is commented out

=======

build.settings:

settings = { iphone = { plist = { UIBackgroundModes = { "remote-notification" }, FirebaseAppDelegateProxyEnabled = false, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, UIApplicationExitsOnSuspend = false, FacebookAppID = "114186XXXXX0197", -- Replace XXXXXXXXXX with your Facebook App ID CFBundleURLTypes = { { CFBundleURLSchemes = { "fb114186XXXXX0197", } } -- Replace XXXXXXXXXX with your Facebook App ID }, -- Whitelist Facebook apps LSApplicationQueriesSchemes = { "fb", -- Needed for the facebook-v4.isFacebookAppEnabled() API "fbapi", "fbauth2", "fb-messenger-api", "fbshareextension" }, }, }, plugins = { ["plugin.notifications.v2"] = { publisherId = "com.coronalabs" }, ["plugin.firebaseAuth"] = { publisherId = "tech.scotth" }, ["plugin.facebook.v4"] = { publisherId = "com.coronalabs" }, }, android = { useGoogleServicesJson = true, facebookAppId = "114186XXXXX0197", -- Replace XXXXXXXXXX with your Facebook App ID }, }

main.lua:

local firebaseAuth = require "plugin.firebaseAuth" local facebook = require( "plugin.facebook.v4" ) local widget = require("widget") local json = require("json") local notifications = require( "plugin.notifications.v2" ) firebaseAuth.init() local loadProfilePage local signOut local signInGroup = display.newGroup( ) local profileGroup = display.newGroup( ) local sceneGroup = display.newGroup( ) sceneGroup:insert( signInGroup ) sceneGroup:insert( profileGroup ) local emailOfAccount = display.newText( profileGroup, "", display.contentCenterX, display.contentCenterY-150, native.systemFont, 15 ) local uid = display.newText( profileGroup, "", display.contentCenterX, display.contentCenterY-100, native.systemFont, 12) local isVerfiyAndAnon = display.newText( profileGroup, "", display.contentCenterX, display.contentCenterY-50, native.systemFont, 12) profileGroup.alpha = 0 local signOutButton signOutButton = widget.newButton( { x = display.contentCenterX, y = display.contentCenterY+200, id = "signOutButton", labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 0, 0.5 } }, label = "Sign Out", onEvent = function ( e ) if (e.phase == "ended") then firebaseAuth.signOut(function (ev) if(ev.isError) then native.showAlert( "Could not Sign Out", ev.error ,{"Ok"} ) else signOut( ) end end) end end } ) profileGroup:insert(signOutButton) local sendVerify sendVerify = widget.newButton( { x = display.contentCenterX, y = display.contentCenterY+150, id = "sendVerification", labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 0, 0.5 } }, label = "Send Verification", onEvent = function ( e ) if (e.phase == "ended") then firebaseAuth.sendVerification(function (ev) if(ev.isError) then native.showAlert( "Could not send email", ev.error ,{"Ok"} ) else native.showAlert( "Email sent", "" ,{"Ok"} ) end end) end end } ) profileGroup:insert(sendVerify) local bg = display.newRect( sceneGroup,display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) bg:setFillColor( 1,.5,0 ) local title = display.newText( {parent = signInGroup,text = "Firebase Auth", fontSize = 30} ) title.width, title.height = 300, 168 title.x, title.y = display.contentCenterX, 40 title:setFillColor(1,0,0) local email = native.newTextField( display.contentCenterX, display.contentCenterY-100, 280, 40 ) signInGroup:insert( email ) local emailText= display.newText( "Email", email.x, email.y-50, native.systemFont, 20 ) signInGroup:insert( emailText ) local password = native.newTextField( display.contentCenterX, display.contentCenterY, 280, 40 ) signInGroup:insert( password ) local passwordText= display.newText( "Password", password.x, password.y-50, native.systemFont, 20 ) signInGroup:insert( passwordText ) local signIn signIn = widget.newButton( { x = display.contentCenterX, y = display.contentCenterY+120, id = "signIn", labelColor = { default={ 0, 0, 0 }, over={ .5, 0, 0, 0.5 } }, label = "Sign In", onEvent = function ( e ) if (e.phase == "ended") then firebaseAuth.signIn(email.text, password.text,function (ev) if(ev.isError) then native.showAlert( "Could not Sign in", ev.error ,{"Ok"} ) else native.showAlert( "Signed in", "" ,{"Ok"} ) loadProfilePage( ) end end) end end } ) signInGroup:insert( signIn ) local createAccount createAccount = widget.newButton( { x = display.contentCenterX, y = display.contentCenterY+80, id = "createAccount", labelColor = { default={ 0, 0, 0 }, over={ .5, 0, 0, 0.5 } }, label = "Create Account", onEvent = function ( e ) if (e.phase == "ended") then firebaseAuth.createAccount(email.text, password.text,function (ev) if(ev.isError) then native.showAlert( "Could not create account", ev.error ,{"Ok"} ) else native.showAlert( "Account Created", "please sign in now" ,{"Ok"} ) end end) end end } ) signInGroup:insert( createAccount ) local signInWithFacebook signInWithFacebook = widget.newButton( { x = display.contentCenterX, y = display.contentCenterY+160, id = "signInWithFacebook", labelColor = { default={ 0, 0, 1 }, over={ .5, 0, 0, 0.5 } }, label = "Sign In with Facebook", onEvent = function ( e ) if (e.phase == "ended") then facebook.login(function ( event ) if ( "session" == event.type ) then if ( "login" == event.phase ) then firebaseAuth.signInWithFacebook(event.token, function ( ev ) if(ev.isError) then native.showAlert( "Could not Sign in", ev.error ,{"Ok"} ) else native.showAlert( "Signed in", "" ,{"Ok"} ) loadProfilePage( ) end end) end end end) end end } ) signInGroup:insert( signInWithFacebook ) signInGroup:toFront( ) profileGroup:toFront( ) Runtime:addEventListener( "touch", function ( ) native.setKeyboardFocus( nil ) end ) function signOut( ) profileGroup.alpha = 0 signInGroup.alpha = 1 email = native.newTextField( display.contentCenterX, display.contentCenterY-100, 280, 40 ) signInGroup:insert( email ) password = native.newTextField( display.contentCenterX, display.contentCenterY, 280, 40 ) signInGroup:insert( password ) end function loadProfilePage( ) profileGroup.alpha = 1 signInGroup.alpha = 0 display.remove( email ) display.remove( password ) if(firebaseAuth.getEmail()) then emailOfAccount.text="Email:"..firebaseAuth.getEmail() elseif firebaseAuth.getDisplayName() then emailOfAccount.text="Name:"..firebaseAuth.getDisplayName() else emailOfAccount.text="Name: Blank" end uid.text = "UID:"..firebaseAuth.getUID() isVerfiyAndAnon.text = "Is Account Verfied?:"..tostring(firebaseAuth.isEmailVerified()).."/ Is Anonymous?"..tostring(firebaseAuth.isAnonymous()) end if (firebaseAuth.isSignedIn() and firebaseAuth.isSignedIn() == true) then loadProfilePage( ) end

Any ideas and help is appreciated :slight_smile:

Thanks,

Chris

Ok, seems like changing config.lua did the trick. Now I dont get the error message above at least.

But: I get a black screen instead.

If I comment out

– firebaseAuth.init()

I can see all the display-objects, but as soon as I click on “register” for example, I get the above error message again.

If I dont comment out

firebaseAuth.init()

I just get a black screen. So it seems the initialization does not work. Unfortunately I dont get an error message, so I have no idea where to look at. Any ideas?

How are you looking for error messages?
 

Rob

Since the Firebase Auth Plugin does not run in Simulator, I have to try it on devices. Unfortunetely

firebaseAuth.init()

does not return anything, so I do not really know how to look for a specific error message. The only thing I can observe is that when commenting out that line, code afterwards is executed, otherwise I just get a black screen.

Guess I’ll narrow it down tomorrow to a tiny project and upload it here :slight_smile:

Thanks Rob so far :slight_smile:

You have to tether your device to your laptop by the USB charging cord then you can either:

  1. Use “adb logcat” which is part of the Android Debug Bridge tools. You will have to install these tools and they run from a command line.

  2. Install Android Studio. I believe you can watch the device’s console log from Android Studio. This requires more resources and takes longer to install, but it’s all done from software and you don’t need the command line.

  3. If you’re using a Mac to build your app, you can have Corona install to the test device for you. Just make sure to not close the dialogs that popup at the end. Switch to the Corona console log window and you will find it’s showing you the device’s console log. This doesnt’ work on Windows.

You can then look for errors being generated by your app.

Rob

Wow, appreciate these ideas a lot, thank you Rob. I have both a windows machine and a macbook, so I’ll try attempt number three tomorrow and look into the console outputs. Thank you sir :slight_smile:

Chris,

I’ve got my own Android problem when I build and load onto device.  You may have the same problem.

When you get your device tethered to your mac then build and copy to device, look in the console and see if you are getting this at the top of the log:

Permission Denial: getCurrentUser() from pid=24646, uid=10183 requires android.permission.INTERACT_ACROSS_USERS

From what I can tell, any app built for Android will kick this warning.  In my case, I actually have the permission set in my build.settings, but I still get the warning.  This Permission Denial on my apps is breaking the google licensing api, it always returns false when it should be true.  When I remove the license requirement, my app continues to load normally.  Similar to you commenting out your authInit() possibly.  Unfortunately I don’t use that plugin so I’m not sure how it works.

Let me know if you see that Permission Denial warning tomorrow near the top of you log. I’m reaching here, but it could be an issue.

Nail

So, I just built the same project files on my macbook and … it works.

Switched back to windows, built the project and … black screen.

Again, back to macbook, built the project and it works again.

Does that make sense to anyone?

Have you reached out to Scott?

Rob

Jup, PMed him two days ago and asked him if - of course payed - teamviewer suppport would be doable. Guess that’s something he doesnt offer or he’s busy at the moment :slight_smile:

I’ll keep trying tomorrow and go over all settings again, chances are high that I made a mistake at some point.

I’ll let you know when I find out where the problem was.

So, current status, all using the same project files:

  • Building .apk on my macbook, sending it right on my Huawei P20lite works. I can use firebaseAuth.sendVerificationCode no problem, a SMS with a code is sent.

  • Building .apk on my Windows 10 machine and transfering it to my P20lite does not work: The app is installed without any problems, but crashes right at launch with following error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzeku;

  • Building .apk on my Windows 10 machine and transfering it to an older Motorola device with Cyanogen-Mod: The app crashes right at the start with following error: java.lang.NoClassDefFoundError: com.google.firebase.auth.FirebaseAuth

My understanding is that since building it on a macbook does work, my firebase settings (SHA1, notification setup and stuff) should be correct.

Do you guys have any idea where to look at now? :slight_smile:

Scott just told me via private message that this should be fixed now and indeed, it is :slight_smile: