Android Question Error when add androidx.datastore:datastore

Pendrush

Well-Known Member
Licensed User
Longtime User
This line
B4X:
#AdditionalJar: androidx.datastore:datastore
require these dependencies:

1734364154727.png

When I try to compile, I get this error:
B4A Version: 13.00
Parsing code. (0.00s)
Java Version: 19
Building folders structure. (0.01s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (0.04s)
Linking resources (0.17s)
build tools: 34.0.0, android jar: android-34
Compiling generated Java code. (0.00s)
Finding libraries that need to be dexed. (0.00s)
Dex code (0.59s)
Dex merge Error
Error in e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.1\unpacked-datastore-core-android-1.1.1\jars\classes.zip:classes.dex:
Type androidx.datastore.core.Actual_jvmKt is defined multiple times: e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.1\unpacked-datastore-core-android-1.1.1\jars\classes.zip:classes.dex, e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-jvm\1.1.1\datastore-core-jvm-1.1.1.zip:classes.dex
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.1\unpacked-datastore-core-android-1.1.1\jars\classes.zip:classes.dex
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1269)
at com.android.tools.r8.D8.main(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.1\unpacked-datastore-core-android-1.1.1\jars\classes.zip:classes.dex
at Version.fakeStackEntry(Version_8.3.37.java:0)
at com.android.tools.r8.Q.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:5)
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:244)
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:90)
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:909)
at com.android.tools.r8.internal.po.b(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:99)
at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1041)
at com.android.tools.r8.D8.b(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:514)
at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1076)
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:1256)
... 1 more
Caused by: com.android.tools.r8.internal.h: Type androidx.datastore.core.Actual_jvmKt is defined multiple times: e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-android\1.1.1\unpacked-datastore-core-android-1.1.1\jars\classes.zip:classes.dex, e:\xsdk\b4asdk\tools\..\extras\b4a_remote\androidx\datastore\datastore-core-jvm\1.1.1\datastore-core-jvm-1.1.1.zip:classes.dex
at com.android.tools.r8.internal.X30.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:346)
at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:232)
at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:91)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
at com.android.tools.r8.internal.pX.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:32)
at com.android.tools.r8.graph.q4$a.d(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:6)
at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:264)
at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:222)
at com.android.tools.r8.dex.c.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:219)
at com.android.tools.r8.D8.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:809)
at com.android.tools.r8.D8.d(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:212)
at com.android.tools.r8.D8.c(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:163)
at com.android.tools.r8.internal.po.a(R8_8.3.37_d0b8d9dfe8720e37c27d2233931d9d72dbd696ffd92111cc9b36e58b4baad1cc:906)
... 6 more

Any workaround?
 

drgottjr

Expert
Licensed User
Longtime User
did you try typing "datastore" in the sdkmanager. looks like they're there ready to go
sorry; i misread the post. probably drunk again
 
Last edited:
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
1. Create empty project.
2. Add this line: #AdditionalJar: androidx.datastore:datastore
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
    #AdditionalJar: androidx.datastore:datastore
#End Region
3. Install all needed dependencies reported by B4A.
4. You are unable to compile.

The problem: duplicated classes inside datastore dependencies.
.Actual_jvmKt is defined multiple times
I know what the problem is. I don't know how to resolve it.
 
Last edited:
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Datastore is dependencies for other lib.
I am trying to create a wrapper library that will be able to be used in B4A.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I was able to get it compiling by removing the jvm dependencies from the POM files.

The attached zip contains the folders that should be under <sdk>\extras\b4a_remote\androidx\datastore

It is possible that you will encounter an error at runtime. I haven't tested the actual functionality.
 

Attachments

  • datastore.zip
    359.8 KB · Views: 5
Upvote 0
Top