Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android api 29 error getting uuid #36

Open
devsgtech opened this issue Aug 14, 2020 · 21 comments
Open

Android api 29 error getting uuid #36

devsgtech opened this issue Aug 14, 2020 · 21 comments

Comments

@devsgtech
Copy link

Exception occurred: getDeviceId: The user 10136 does not meet the requirements to access device identifiers.

@Anujmoglix
Copy link

same issue in my case , I am not able to fix that .

@TriyogaDibrata
Copy link

i got same issue, any solution?

@assafnoahkoren
Copy link

I got this error also, someone managed to find an alternative?

@Anujmoglix
Copy link

I think no one is managing it and I am also getting issue with permission . I have added android phone state permission but in many device I am getting null .Anyone have any idea ?

@devsgtech
Copy link
Author

You can try this link
https://ionicframework.com/docs/native/uid

@B0rrA
Copy link

B0rrA commented Sep 30, 2020

You can try this link
https://ionicframework.com/docs/native/uid

The native pluggin of ionic refferes to this same code so...

@Anujmoglix
Copy link

Any update ?

@stanstanov
Copy link

I have this problem too :(

@greaterking
Copy link

Same issue ...will this be updated soon?

@greaterking
Copy link

If anyone finds an alternative please post back..thanks.

@Anujmoglix
Copy link

I used https://ionicframework.com/docs/v3/native/device/. (uuid of it ) . this is only way to work

@greaterking
Copy link

Does the uuid persist across multiple installs?

@Anujmoglix
Copy link

yes , I tried with multiple device and multiple install & uninstall . It is working fine and I am using in end user app . I didn't get any issue yet . You should try and check .

@greaterking
Copy link

@Anujmoglix Will test and report back ...thanks.

@Qsaws
Copy link

Qsaws commented Dec 4, 2020

I used https://ionicframework.com/docs/v3/native/device/. (uuid of it ) . this is only way to work

I had moved away from that plugin for UUIDs to this one because the UUID didn't persist between installs on iOS, guess i'll have to use both until there is a fix for android on this one.

@RameshSenagasetti
Copy link

RameshSenagasetti commented Dec 4, 2020

I managed to solve the issue by updating few lines in UniqueDeviceID.java and things started work as it was before wrt deviceID.

imported android.os.Build to the file.

import android.os.Build;

and updated getDeviceId method as below

protected void getDeviceId(){
> boolean isAndroid10 = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q;
try {
Context context = cordova.getActivity().getApplicationContext();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        String uuid;
        String androidID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
        **_String deviceID;
        String simID;_**

        if ("9774d56d682e549c".equals(androidID) || androidID == null) {
            androidID = "";
        }

        **_uuid = androidID;_**

        **_if ( !isAndroid10 ) {
            deviceID = tm.getDeviceId();
            simID = tm.getSimSerialNumber();
            if (deviceID == null) {
                deviceID = "";
            }
            if (simID == null) {
                simID = "";
            }
            uuid = androidID + deviceID + simID;
        }_**            
        uuid = String.format("%32s", uuid).replace(' ', '0');
        uuid = uuid.substring(0, 32);
        uuid = uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5");

        this.callbackContext.success(uuid);
    }catch(Exception e ) {
        this.callbackContext.error("Exception occurred: ".concat(e.getMessage()));
    }
}

see if it works for you. (you should remove and add the android platforms again once the plugin is updated with these changes)

@greaterking
Copy link

greaterking commented Dec 17, 2020

@RameshSenagasetti I can confirm this is working. However two things to notes

1. getDeviceId is deprecated https://developer.android.com/reference/android/telephony/TelephonyManager#getDeviceId(int)
2. not sure if the id is persist(is non-resettable) through uninstalls or key signing

let me know otherwise.

@greaterking
Copy link

greaterking commented Dec 17, 2020

UPDATE

Correction @RameshSenagasetti I see you are only using getDeviceId for everything lower than android 10 which is what is was doing before.

I was under the impression though that you need READ_PRIVILEGED_PHONE_STATE for Android 10 >= ??

@greaterking
Copy link

This thread might be useful to the conversation to officially fix this plugin https://stackoverflow.com/questions/4799394/is-secure-android-id-unique-for-each-device

@AmilaJJ
Copy link

AmilaJJ commented Apr 20, 2021

I am also getting this error. Any updates ?

@Adm94
Copy link

Adm94 commented May 10, 2021

Two of three data used to generate the uniqueId are now no more accessible for Android 10.
They are :

  • TelephonyManager # getDeviceId
  • TelephonyManager # getSimSerialNumber

See here

So I think the idea of @RameshSenagasetti to only use Secure.ANDROID_ID when the device version is equal or more than Android 10 is good.

But there will be some problem with devices being updated from Android 9 and less to 10 knowing that the generated ID will no more match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests