Unity Android Build get error "Insufficient system permissions"

I am developing an application in the Unity environment.
When I compile the license check for Windows, everything works correctly.
However, when I switch the build to Android, I receive the error "Insufficient system permissions" at

LexActivator.SetProductId(idString, LexActivator.PermissionFlags.LA_USER);

If I use the flag LA_IN_MEMORY, the error doesn’t occur, but every time I reopen the application, it prompts for a new license activation.

In the manifest, the following permissions are defined:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

In Gradle, the following dependency is defined:

implementation 'com.cryptlex.android.lexactivator:lexactivator:3.31.3

Unity version: 2022.3.51f1
LexActivator version: 3.31.3

Hi @ra001,

Thanks for reaching out!

If I use the flag LA_IN_MEMORY , the error doesn’t occur, but every time I reopen the application, it prompts for a new license activation.

Since you are passing LA_IN_MEMORY as a permission flag to SetProductId() which stores activation data only in the memory which means when the app is restarted the activation information is removed too. Please try using the LA_USER flag instead.

In the manifest, the following permissions are defined:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

You need to ensure that the above two permissions are set in the Android manifest which the LexActivator library requires. However if you have already defined these, I will get in touch with my team to check further and keep you posted here!

Hi.
I check permission with

bool hasPermission = Permission.HasUserAuthorizedPermission("com.google.android.providers.gsf.permission.READ_GSERVICES");

And answer is true, that means permission is set and manifest is correct, but still I get Insufficient system permissions error

Hi @ra001,

Could you please help us with the Android version being used?

Also, it would be really helpful if you could try to reproduce the issue using our sample Android application: lexactivator-android/examples at main · cryptlex/lexactivator-android · GitHub

Android 14 (Samsung S22)
I see this example, but we need build in Unity, becouse we need use it in VR application.

Hi @ra001

It looks like the issue might be related to how Unity handles application sandboxing on Android. Unity apps run in a managed environment that may prevent LexActivator for Android from accessing the app’s private internal storage to store the license data. This can lead to the “Insufficient system permissions” error you’re seeing when using LA_USER.

One thing you can try is using the SetDataDirectory() function provided by the SDK, which allows you to specify a custom path for storing license data. We recommend setting this to a path that’s writable by your Unity app — for example:

LexActivator.SetDataDirectory(persistentDataPath);

This ensures that LexActivator can persist license data in a location that complies with Android’s storage model and Unity’s sandboxing rules.

O, BIG thank you!
It`s working now!

p.s
(I try compile mobile example, but get windows blue screen)

In Unity XR (Oculus Quest 2/3) licence activator is working.
Thank you again.

Hi @ra001,

Glad to know that it’s working. If you need any further assistance or run into any other issues, feel free to reach out to us at support@cryptlex.com anytime, we’re happy to help!