Beta B4A v9.80 BETA #2 Uncaught translation error

moster67

Expert
Licensed User
Longtime User
Unsure if this is related to the B4A v9.80 #2 beta or my newly wrapped library.

I have 2 Android SDK folders, both located in C on my harddrive. One is the standard one I am using with Android Studio whereas the 2nd one I have called AndroidSDKB4A which I am keeping update using B4A's SDK Manager. In B4A's IDE configuration path I am pointing normally to the latest android.jar present in AndroidSDKB4A

The library I have wrapped is using Target SDK 29 because there are some methods that are optimized for SDK29. If the device is not SDK29, those methods will be skipped.

When trying to compile with android.jar (v. 29 but also v 28) pointing to AndroidSDKB4A, I get the following error:
B4X:
B4A Version: 9.80 BETA #2
Java Version: 8
Parsing code.    (0.00s)
Building folders structure.    (0.18s)
Compiling code.    (0.05s)
Compiling layouts code.    (0.02s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Generating R file.    (0.54s)
Compiling debugger engine code.    (1.22s)
Compiling generated Java code.    (2.02s)
Convert byte code - optimized dex.    Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/AnimRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/AnimatorRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/AnyRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/AnyThread;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/ArrayRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/AttrRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/BinderThread;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/BoolRes;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroidx/annotation/CallSuper;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
    at com.android.dx.command.dexer.Main.runDx(Main.java:293)
    at com.android.dx.command.dexer.Main.main(Main.java:249)
    at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:684)
    ... 4 more

If I, however, configure the B4A IDE configuration to use the andoid.jar in my standard Android Studio SDK folder, the project compiles just fine.

Both SDK locations are up-to-date. Unfortunately, I did not install the beta in a separate folder so I am unable to test with the earlier version.

As I said, I am not really sure what the problem is. It seems odd.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Are you using any android support annotation library in your project? Sounds like it is added twice. Maybe android support and a new one from androidx?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Yes, I am using androidx annotations. But still I don't understand why it compiles fine with one android.jar and with the other one it does not work?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I am not at the computer now but I think I am using exclusively androidx. Also in my first post you can see it is using androidx SDK.
I will check better tomorrow.
But I still don't understand the different behavior between the Android.jars.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Also in my first post you can see it is using androidx SDK.
i should have looked more carefully ;-)

Ok, you are using AndroidX. So i suggest to check if there is not - accidentially - a old android support annotations referenced too. If so; remove it.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Just checked using the search function in Android Studio (there are hundreds of classes) but I couldn't find imports for android.support. Searching for "annotation, I could only find references to androidx.annotation.
I noted that when compiling with the android.jar from the AndroidSDKB4A, then the error log shows AndroidX SDK but fails. When using android.jar from the standard SDK folder, and which works, the compiling windows in B4A show ANdroid Support Library.

I am at loss here....
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
There is no need to migrate since the AS project is very much up-to-date.
Anyway, using the option found in Refactoring in AS (as you suggested), I get a message there are no usages (i.e. nothing to migrate).

In the original project, there are 4 library projects where one depends on the other 3. What I have basically done, is to compile the project, and use the 4 aar-archives in my wrapper (as I usually do) and then write my own classes on the top using such aar-archives and then create a B4A-wrapper. You may be right that there are duplicates of classes among the 4 aar-archives so that is something I should probably verify.
However, it is still odd that using the android.jar in the standard SDK, I have no problems compiling in B4A but with the other android.jar, I will get the error posted in my first post.

Just wondering if B4A somehow reads my Android SDK environment path which points to the standard Android SDK location and if this can cause any problems but then again, I have not changed anything, apart from installing the new beta, and everything, until yesterday, was working just fine.

I am going to uninstall my AndroidSDKB4A folder and create a new one. Maybe it got "polluted" somehow.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i would check all involved libs/aar if there is maybe a android support annotation jar included (which should not be included; it is only used at compiletime).

This is the only thing i can imagine. I do not use AS to develop wrappers though. Only use it to create AAR from a Project. I use the classes.jar from the AAR in my Eclipse project.

I always do compile my Libraries with SLC using the AndroidX B4A SDK.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I also use the classes.jar (extracted from the AARs) and compile them with SLC. In this case, there are 4 of them so I renamed them and put them in the lib-folder as SLC needs them during compiling. In my wrapper class, I use the @dependson annotation to point to the AAR-archives (which have been copied into the Additional Library folder in the B4A folder). I prefer using the AAR-archives, instead of the renamed classes.jars in my wrappers, since the AAR-archives can include Resources, Views and so on.

I checked and searched again the original AS-project and there are no references to any android.support/annotation jars.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Deleted the old AndroidSDKB4A folder and reinstalled a new one as per B4A instructions but still the same problem.

I don't know what is happening here. Surely there are duplicates, for instance, I can see "already added: Landroidx/annotation/BinderThread" and other similar errors. But what I don't understand is why this is ignored when using standard android.jar. It is as if using the android.jar in the AndroidSDKB4A folder, a more complete verification is made.

I am going to recompile the AS project and generate new AARs, one by one, and see if this resolves the issue.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
may you want to send me the wrapper source incl. all files/aar/jar? You can send it in a conversation. I´ll not give away anything; just want to try to help ;-)
Thanks. Much appreciated. I will do a few more tests and if it still failing, I will contact you in PM.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Don, your last post got me thinking. For some reason, in the @DependsOn annotation, I had included the androidx annotation-1.1.0.jar and this one was surely also included in the AAR-packages too and therefore there were duplicates. Removing it, everything compiles fine. :)
Thanks for helping me out @DonManfred 👏

However, I am still curious why it compiled fine when pointing to one android.jar but not with the other one. 🤔

Anyway, now it is working.
 
Upvote 0
Top