Android Question Error when compiling the CASTY library example.

Alejandro Viera

Member
Licensed User
I am trying to compile the CASTY library example and I get the following error, any clue to solve it?

Thank you!

Compile Error:
B4A Versión: 12.50
Parseando código.    (0.04s)
    Java Versión: 11
Building folders structure.    (0.20s)
Compilando código.    (0.05s)
Compilado códigos de diseños.    (0.01s)
Organizando librerías.    (0.00s)
    (AndroidX SDK)
Compilando los recursos    (0.30s)
Enlazando los recursos    (7.19s)
Compilando el código Java generado.    (0.50s)
Buscando librerias que necesitan ser dexed.    (0.06s)
Dex code    (3.65s)
Dex merge    Error
Error in C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-1-63696197135763\dex_v1\javax.inject-1.zip:classes.dex:
Type javax.inject.Inject is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-1-63696197135763\dex_v1\javax.inject-1.zip:classes.dex, C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-javax.inject-63822340562000\dex_v1\javax.inject-javax.inject.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_local\unpacked-javax.inject-1-63696197135763\dex_v1\javax.inject-1.zip:classes.dex
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:98)
    at com.android.tools.r8.D8.main(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-1-63696197135763\dex_v1\javax.inject-1.zip:classes.dex
    at Version.fakeStackEntry(Version_3.3.20-dev+aosp1.java:0)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:75)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:27)
    at com.android.tools.r8.internal.vj.b(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:2)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:17)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:85)
    ... 1 more
Caused by: com.android.tools.r8.internal.f: Type javax.inject.Inject is defined multiple times: C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-1-63696197135763\dex_v1\javax.inject-1.zip:classes.dex, C:\Android\tools\..\extras\b4a_local\unpacked-javax.inject-javax.inject-63822340562000\dex_v1\javax.inject-javax.inject.zip:classes.dex
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:14)
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:36)
    at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:10)
    at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
    at com.android.tools.r8.internal.cN.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:6)
    at com.android.tools.r8.graph.E2$a.e(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
    at com.android.tools.r8.dex.b.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:105)
    at com.android.tools.r8.dex.b.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:25)
    at com.android.tools.r8.D8.d(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:609)
    at com.android.tools.r8.D8.c(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:1)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:24)
    ... 5 more
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've downloaded the library and the example.

- For some reason I needed to change "cast" with "cast1"
- And add: #MultiDex: True

It then compiled successfully

B4A Version: 12.50
Parsing code. (0.01s)
Java Version: 14
Building folders structure. (0.04s)
Compiling code. (0.01s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (0.05s)
Linking resources (1.09s)
Compiling debugger engine code. (0.00s)
Compiling generated Java code. (0.13s)
Finding libraries that need to be dexed. (0.00s)
Dex code (0.49s)
Dex merge (3.25s)
Copying libraries resources (1.40s)
ZipAlign file. (0.08s)
Signing package file (private key). (0.46s)
 
Upvote 0

Alejandro Viera

Member
Licensed User
Thanks Erel, I don't have the same luck. I made the changes that you recommend, I even updated JAVA to version 14.

The truth is that now I get this error on the next line.

cast1.Initialize("Casty") '"4F8B3483" ' "E3AAA8CE")

B4X:
Error occurred on line: 36 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at de.donmanfred.CastOptionsProvider.getCastOptions(CastOptionsProvider.java:31)
    at com.google.android.gms.cast.framework.CastContext.getSharedInstance(com.google.android.gms:play-services-cast-framework@@21.2.0:6)
    at de.donmanfred.Castywrapper.Initialize(Castywrapper.java:81)
    at de.donmanfred.cast.main._activity_create(main.java:395)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at de.donmanfred.cast.main.afterFirstLayout(main.java:105)
    at de.donmanfred.cast.main.access$000(main.java:17)
    at de.donmanfred.cast.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:250)
    at android.app.ActivityThread.main(ActivityThread.java:7851)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
** Activity (main) Resume **
 
Upvote 0
Top