1

the google login works in simulator but the app crashes in all devices i checked.

sign.addActionListener((e) -> {
    String clientId = "704790222159-n1cpb3g1q3plirslu5739apc0gnnv4pp.apps.googleusercontent.com";
    String redirectURI = "https://www.youtube.com/";
    String clientSecret = "q_cxGCCbX5GVC99kxgstjksB";
    gc = GoogleConnect.getInstance();
    gc.setClientId(clientId);
    gc.setRedirectURI(redirectURI);
    gc.setClientSecret(clientSecret);
    gc.setScope("https://www.googleapis.com/auth/youtube.force-ssl");
    gc.setCallback(new LoginCallback() {
        @Override
        public void loginFailed(String errorMessage) {
            Dialog.show("Error Logging In", "There was an error logging in: " + errorMessage, "OK", null);
        }

        @Override
        public void loginSuccessful() {
            Dialog.show("Logged In", "you are currently logged in ", "OK", null);
        }
        });
        if (!gc.isUserLoggedIn()) {
            gc.doLogin();
        } else {
            token = gc.getAccessToken().getToken();
        }
});

In simulator following login page appears and it works fine but in real devices the login page(allow/deny page) doesnt appear after i sign in ,and then app crashes after a while

enter image description here

error log:

error log

verbose log:

device error log

beck
  • 2,967
  • 3
  • 16
  • 27
  • One more thing, do i need to include any build hints for android in project properties? – beck Apr 04 '16 at 10:32
  • Hint : You should not include authentication keys in your posts here at StackOverflow... – Daniel Bleisteiner Apr 08 '16 at 05:25
  • Thanks @DanielBleisteiner I was jst trying the project. This is not real project. As soon as i get it right, i'll get new keys. I included the keys so that if sm1 tries the code, they shouldnt bother with the keys. – beck Apr 08 '16 at 06:06
  • I am getting a similar error. Except the permission failure is with android.permission.GET_ACCOUNTs. Tried adding the android.xpermission build hint but still not working. Error only happens on android 6. Obviously a problem with the marshmallow permissions. Any idea how to fix? – Kyri33 Jun 27 '17 at 15:49

2 Answers2

1

I debugged a similar problem yesterday. It's because the app isn't being given proper permissions. If you manually grant the permissions on your device (under settings->apps->your app) the login with Google will work fine (at least with Android, iOS I still can't get to work, it just spins endlessly).

It's build mysteries like this that aren't explained in any documentation that prevent me from getting invested in codename one, unfortunately. It seems to have so much potential but I'm constantly up against the wall with issues just like this that reduce my productivity.

Scott Turner
  • 133
  • 5
  • Update: I may have been overly harsh on my criticism of CN1. After some further POC work, I've found that I'm able to do most things I need to do (communication with PHP, uploading/downloading files, facebook login, GPS and map features) with relative ease, especially compared to Xamarin. The google login is really the only issue I've had that I can't figure out. – Scott Turner May 05 '17 at 18:08
0

The simulator uses all of these hints which work for the web login fallback. The device uses native login which is defined thru a combination of build hints and website configurations.

I suggest reading this section of the developer guide.

I would also suggest connecting a cable to an Android device and using the Android SDKs DDMS tool to debug crashes of this type.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • i kept all the build hints like android playservice,auth to true but same result. There is client id and client-secret under web client and there is only client id in android client. I kept the web client and secret. Is it the reason why it runs ok in simulator and not in devices? If so there is no client secret in android client, What should i keep in client secret – beck Apr 05 '16 at 08:03
  • Does your package, key/SHA match your definition within the Google project? – Shai Almog Apr 06 '16 at 02:54
  • yeah all match. Can i debug creashes of cn1 apk in android studio as u mentioned in ur ans & how? – beck Apr 07 '16 at 00:38
  • Yes http://stackoverflow.com/questions/34430404/how-to-build-the-native-android-sources-from-codename-ones-build-server/34431311#34431311 however to just see the reason for the crash you can use the DDMS tool from the SDK and get the log from the device – Shai Almog Apr 07 '16 at 03:26
  • thanks i have updated the device error log link above. please hav a look – beck Apr 07 '16 at 05:20
  • Try embedding instead of linking to google drive which is really inconvenient. What build hints did you define? – Shai Almog Apr 08 '16 at 03:40
  • As i already mentioned in a comment above,i used android playservice, auth to true. However i checked without using any build hints as it is mentioned that if you dont define any, they'll be true by default. Moreover i define all of the android build hints mentioned in "advanced topic of developers guide" as well in a separate project but doesnt work – beck Apr 08 '16 at 04:52
  • It seems there might have been an issue there. We just deployed an update that might resolve that issue. – Shai Almog Apr 10 '16 at 02:50
  • The update is already deployed so new builds should work instantly. – Shai Almog Apr 11 '16 at 02:46