Android login issue

Thanks Nate, that’s a big help, I’ll go down the webview route I think. I’ve read a lot on forums about the android webview cookie manager, I just couldn’t get the equivalent in Cordova. I’ll let you know if that fixes the issue! Thanks again.

1 Like

@natedogg this android thing is driving me to despair. I just can’t get the webview to pass the bubble cookie to device storage. Didn’t you have any cookie related issues?

@richardosborne14 I haven’t had any issues with cookies. In fact, I just built another android file today for a client, and the login workflow was fine.

Does it happen anywhere else at all, say in a web or mobile browser? Any chance the device that you’re testing on has issues with receiving cookies? Other than that, I’m not really sure, as I don’t know exactly what you’ve done so far.

@natedogg thanks for the reply again. That’s the funny thing, login workflow works fine in all other instances. I’ve tested in:

  • Mac OSX El Capitan - Safari + Chrome + Firefox
  • Windows 7 - Chrome + IE
  • iPhone 6 iOS 9.3.2 - Safari + Ghostery
  • iPhone - as a native app using only the files sent by Bubble uploaded to build.phonegap.com
  • Android - Chrome browser

The only one that’s bugged is the Android native app, with this repeating error that it can’t read the Firebase file that Bubble should store in localstorage with a Firebase authentication token. This stores fine in all other instances, I think (though I can’t view it in iOS - no access).

I think it’s localstorage and not cookies because I can see a table with Firebase auth info in localstorage in Safari dev view, and then two empty cookies named after the Firebase username in cookie storage. Also, I can replicate a Bubble error “Please enable cookies” by disabling cookies in a browser, but I can’t replicate the “Your session has expired” error I get with Android webviews.

Ive used the basic Phonegap build, a Cordova custom build, Cordova imported into Android Studio, an Android Studio build from scratch, I’ve tested in a real Nexus 5, an emulated Nexus 5X (api 21) and an emulated Nexus One (api 18) with exactly the same result every time. I’ve tried setting the Android MainActivity with every js setting under the sun (cookie manager, enabling database and local storage, file scheme cookies, etc.) but it’s always the same result.

@emmanuel, I really understand that you don’t support android, but there must be some simple, fundamental mistake with the zip file I was sent for the Phonegap build that makes it bug when loaded through a webview. Could you at least check the files you sent me for any anomalies or resend a freshly made one please? I can’t find any other solution since @natedogg is trying the same thing I am with no storage issues.

Best you can do is try again from the initial zip. We’ve never tried with android so I don’t know if it works.

Thanks Emmanuel. I did try with the initial zip, exact same error. Are you sure there could be no difference or mistake in the zip I received? I’d like to receive a fresh copy just in case if you could do that for me please.

Email support with the usual info.

I supposed you already tried with another Android phone? We have 2 Samsung Android if you want me to test.

I don’t have another physical one, though I could try to get one. But I’ve tried one physical and two different emulated phones as I said in my post.

We have 2 Samsung Android if you want me to test. No experience on Android, but building soon Android… iOs already working.

That’s very kind, thanks John! I’ll let you know when I’m testing again and send you the apk :slight_smile:. Have you already successfully developed a Bubble Android native app?

Going back to basics has really revealed some important insights.

I just set up a basic Android Studio project, just the basic webview shell. I didn’t load any of the Bubble zip file contents (Phonegap stuff) and just asked MainActivity to load my production url.

The regular web address (www.activateenglish.com) loaded fine, logged in, no major errors in the logs. The bubble supplied web url equivalent for Phonegap (https://activateenglish.bubbleapps.io/index) took a long time to load, threw up errors about localstorage not existing, then said something beautiful: “authorised successfully for firebase.” Log in works fine, session is persistent, all clear.

That means somewhere between the basic android shell build and the Bubble supplied Phonegap build lies the problem. I’ll keep looking and keep posting updates, though forgive the obvious noobness of someone with no coding experience trying to work this out in these posts.

2 Likes

Ok, so debugging the Android WebView with Chrome Dev Tools revealed the problem:

Because Phonegap is loading a local index.html into the WebView, the Chrome engine doesn’t load the necessary cookies to auth to Firebase (it says local file cookies are blocked by default). None of the additional javascript arguments out there (setAcceptFileSchemeCookies etc.) made a difference, and I’ve been trying so many for so long I’m giving up on that line of inquiry.

However, a really simple change - making the content src=“https://(myapp).bubbleapps.io” in config.xml in the Phonegap build, seems to work perfectly. This way, the WebView loads the usual Firebase auth cookies and tokens because the source isn’t local.

I can’t tell for the moment what kind of Phonegap / Bubble plugins will malfunction, and I’m sure for a more complex app this wouldn’t be a good solution, but for me it’ll have to do. Thanks again to everyone for their help, and I hope this can help other developers in the future.

3 Likes

But wait hair-pulling fans, there’s more!

The Bubble app’s address being https, Android versions higher than API 21 won’t allow mixed http requests inside the WebView (and I was loading iframes inside the app that were now blank and throwing up something like “mixed http request blocked” in the Chrome log).

For me, the Phonegap / Cordova solution was to edit the MainActivity.java file in the Android build to look like this:

`package activateenglish.bubbleapps.io;

import org.apache.cordova.*;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by in config.xml
loadUrl(launchUrl);

    // Allows mixed requests in Cordova's WebView client
    WebView webView = (WebView)appView.getEngine().getView();
WebSettings settings = webView.getSettings();
    if (Build.VERSION.SDK_INT >= 21) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
}

}`
Hope this helps, and I look forward to more steps forward!!

1 Like

P.S. The Ziggeo video recorder is now appearing in the Android build, which is something I posted a bug about a while back here:

Clicking the record button does nothing at the moment, but it’s there - so that’s a start. I’ll post more when I know more.

I’m having the same issue here.

When i try and login, nothing happens and the bar just loads very slowly… then when i close the app completely and re-open it, it must sense that I am in-fact logged in and bring me to the main 'view" but why won’t it log the user in and continue to the proper view is the question? It hangs.

@natedogg in your course, (which I’m enrolled in and is great by the way), it specifies to use a certain version which works on 94% of android devices.

I guess between the time you did the video and now there is a version that will get you 97% of the android devices out there (Icecream i believe it is) - could this be my problem?

Do we need to follow your video exactly? I figured 94% vs. 97% of devices was best and went for it.

@JustinC,

Curious, are you inputting a custom domain into Android Studio, or your Bubble domain?

Bubble domain.

It seems to log the user in but won’t change the view.

You need to close down the app completely and then open it again and because i have the app set to “if logged in go to X-view” it works correctly.

So it appears to be saving the session but it’s not moving people forward past login or register.

Has anyone built an android app successfully that logs in?

What could be my problem if so?

This is what I’m facing: https://appetize.io/app/q3aq6kf17256c12a5uvyjv2zem

It simply doesnt sign users up or hold a session as logged in.

Hey guys, sorry it took so long to reply.

My android app worked with the login only after I successfully edited the MainActivity file to allow “MixedContentMode” which lets the HTTPS bubble URL store cookies. (See my post above)

Have you tried that solution, or do you need help finding the MainActivity file?

1 Like