Android Question androidx.datastore:datastore error,existing forum solution not working for me

omo

Active Member
Licensed User
Longtime User
This error below occured while trying to run Unity Ads SDK standalone example.
Below is the compilation error:
Unity ads Error in Compilation:
B4A Version: 13.40
Parsing code.    (0.02s)
    Java Version: 19
Building folders structure.    (0.08s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.04s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.27s)
Linking resources    (0.39s)
    build tools: 36.0.0, android jar: android-36
Compiling generated Java code.    (0.04s)
Finding libraries that need to be dexed.    (0.01s)
Dex code    (1.83s)
Dex merge    Error
Error in c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.2.1\unpacked-datastore-core-android-1.2.1\jars\classes.zip:classes.dex:
Type androidx.datastore.core.Actual_jvmKt is defined multiple times: c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.2.1\unpacked-datastore-core-android-1.2.1\jars\classes.zip:classes.dex, c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-jvm\1.2.1\datastore-core-jvm-1.2.1.zip:classes.dex
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.2.1\unpacked-datastore-core-android-1.2.1\jars\classes.zip:classes.dex
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:131)
    at com.android.tools.r8.D8.main(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.2.1\unpacked-datastore-core-android-1.2.1\jars\classes.zip:classes.dex
    at Version.fakeStackEntry(Version_8.10.9-dev.java:0)
    at com.android.tools.r8.Q.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:5)
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:82)
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:32)
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:31)
    at com.android.tools.r8.internal.lv.b(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:2)
    at com.android.tools.r8.D8.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:30)
    at com.android.tools.r8.D8.b(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:23)
    at com.android.tools.r8.D8.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:28)
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:118)
    ... 1 more
Caused by: com.android.tools.r8.internal.g: Type androidx.datastore.core.Actual_jvmKt is defined multiple times: c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.2.1\unpacked-datastore-core-android-1.2.1\jars\classes.zip:classes.dex, c:\android\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-jvm\1.2.1\datastore-core-jvm-1.2.1.zip:classes.dex
    at com.android.tools.r8.internal.Cf0.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:21)
    at com.android.tools.r8.internal.Z70.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:54)
    at com.android.tools.r8.internal.Z70.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:10)
    at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
    at com.android.tools.r8.internal.Z70.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:6)
    at com.android.tools.r8.graph.w4$a.d(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:6)
    at com.android.tools.r8.dex.c.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:56)
    at com.android.tools.r8.dex.c.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:12)
    at com.android.tools.r8.dex.c.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:9)
    at com.android.tools.r8.D8.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:33)
    at com.android.tools.r8.D8.d(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:20)
    at com.android.tools.r8.D8.c(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:66)
    at com.android.tools.r8.internal.lv.a(R8_8.10.9-dev_f905a40d39f4d794ae8b29cac7aab17845d8afd626bb44dcc4e5b8898367cac3:28)
    ... 6 more

I downloaded datastore folder here: https://www.b4x.com/android/forum/t...oidx-datastore-datastore.164656/#post-1009464 but couldn't solve my problem. Another more recent datastore folder from Erel not available anymore here: https://www.b4x.com/android/forum/threads/unity-ads-library.120648/page-2#post-1021660
 

aeric

Expert
Licensed User
Longtime User
You can download it from SDK Manager.

1779291299204.png

1779291545220.png
 
Last edited:
Upvote 0

omo

Active Member
Licensed User
Longtime User
I just make a guess.
Have you tried click on the menu Tools -> Jetifier?
Hi, Aeric; thank you so much. Although,
I don't think manual jestification is needed for modern Maven via #AdditionalJar. I expected downloading of exact correct version to happen automatically at build time.

However, I still carried out that manual jestification in accordance with your instructions, but I found out is not the problem.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Hi, Aeric; thank you so much. Although,
I don't think manual jestification is needed for modern Maven via #AdditionalJar. I expected downloading of exact correct version to happen automatically at build time.

However, I still carried out that manual jestification in accordance with your instructions, but I found out is not the problem.
Ya, I just read it only needed for android support libraries.
 
Upvote 0

omo

Active Member
Licensed User
Longtime User
Ya, I just read it only needed for android support libraries.
Is there any reason for me to download again because when I went into the exact datastore folder; I found out I have 2 folders in datastore-core-android which are: 1.1.7 and 1.2.1 folders. In folder 1.1.7 are files you displayed above in your previous response. My program is referencing 1.2.1 that is more recent. If I download another version, it may not solve the problem since the problem is multiple error related
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Maybe the Unity Ads SDK you are using is only compatible with a specific version.

If version 1.1.7 and 1.2.1 are not working for you, try download version 1.1.1
https://www.b4x.com/android/forum/t...oidx-datastore-datastore.164656/#post-1009464

I'm using datastore from this post, and everything is good.
Latest datastore version is v1.1.7 but from this post is v1.1.1.
It compiles and work as it should.

or maybe the problem is due to the jvm dependency mentioned by Erel.
I was able to get it compiling by removing the jvm dependencies from the POM files.
 
Upvote 0
Top