Android Question Uncaught translation Error of Byte-Code

Guenter Becker

Active Member
Licensed User
Hello,
I'm testing my new library FoldableMenue in Deep.

In a test B4A project I activated alle needed library ref included FoldableMenu lib.
In B4XMainPage I setup the menu.

Running the App in Release or Debug Mode on the real device or Emulator I get the following error message:

B4A Version: 10.2
Java Version: 8
Parse den Code. (0.20s)
Building folders structure. (0.05s)
Führe individuellen Aktion aus. (0.08s)
Kompiliere den Code. (0.35s)
Kompiliere Layoutcode. (0.01s)
Organisiere Libraries. (0.00s)
(AndroidX SDK)
Generiere R Datei. (0.00s)
Kompiliere Debugger-Code (1.64s)
Kompiliere generierten Java Code. (1.56s)
Byte-Code konvertieren - optimiert dex. Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lb4a/example/b4xbitset;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lb4a/example/b4xbytesbuilder;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lb4a/example/b4xcollections;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lb4a/example/b4xorderedmap;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lb4a/example/b4xset;
5 errors; aborting

If I do not implement FoldableMenu lib and I implement the FoldableMenu-Class-Module it all works.
I created the FoldableMenu lib by Menu Project/Compile to Library.

Can anyone tell me whats going wrong here?

Best regards
Stay well Günter
 
Last edited:

eps

Expert
Licensed User
Longtime User
Upvote 0

Guenter Becker

Active Member
Licensed User
That's whats strange to me.
The FoldableMenu Lib is a customized view with designer support. In the Project where I compile the lib from I have only B4XCollections and StringUtils referenced.

For testing I use a clean B4XPages Test Project.
I have only B4XPages , Core and FoldableMenu lib referenced in the test project and nothing else.
May be Erel or anybody else knows if he comes to get notice of this thread.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
You already included B4xCollections code in your FoldableMenu.jar so try unchecking the reference in the libraries tab.

Thank you for replying but if you look on my prior reply to 'eps' you may notice that I did not check any reference in my test project except FoldingMenu, B4XPages and Core!

Also I am a little bit confused. I understand that a library being used by a custom view developer is automatic referenced and loaded if the user uses the custom view in his project. Therefore it is not neccessary to tell the user what libs are used of the custom view. The consequence of this referencing concept is that it is normal life that a developer may activate libraries and that one ore more of them have also been referenced inside the custom view. He will do that because he do not know about the used referencies inside the custom view.

Following this logic the reason of the named error can not be found in referencing a lib more often.
If it is the reason this must be a bug otherwise the custom view concept may have a leak and is out of order. I can't belive that.


I do not know but up to now all the answers do not lead me to a solution, sorry.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Following this logic the reason of the named error can not be found in referencing a lib more often.
If it is the reason this must be a bug otherwise the custom view concept may have a leak and is out of order. I can't belive that.
I can´t believe that you did not uploaded the lib, lib source and an example project showing the problem.
All we can do is fishing. I hate fish.
 
  • Like
Reactions: eps
Upvote 0

Guenter Becker

Active Member
Licensed User
Ok,
Lets make it more cruel..
A. I attached the test project with the referenced compiled lib file and the error is the problem we talk about.
B. 2nd I attached testB project with the customview as class. If I run this project I got the answer error: cannot install test.apk downgrade error?
C. I have another project (to big to download) using the compiled view I got the same error as in A.
D. In the C project if I use the class version all is good and the menu works!!

I checked the differencies between the projects. All Manifests are the same and all needed basic codes for the main and the pages are the same.
 

Attachments

  • test.zip
    10.1 KB · Views: 161
  • testB.zip
    13.6 KB · Views: 159
Upvote 0

agraham

Expert
Licensed User
Longtime User
Like I said already, the problem is that you have compiled the B4xCollections code into your FoldableMenu.jar. B4XPages depends on B4XCollections so that library is referenced automatically which clashes with the same code in your library. I have never compiled a library from B4X code, all my libraries are written in Java and separately compiled. so I don't know an immediate solution to this but I am sure there is a simple resolution. In principle your library needs to reference B4XCollections and not include it.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Thank you agraham I think we are comming closer to the solution.

I am an B4A Developer. I developed the customview class by starting a standard B4A Project. 2nd I added the custom view class and coded it. To get no errors while coding I have to reference to the libs I need in the project. 3rd I compile by using the command in the project menu of the gui to compile to library. Thats all.

Please can you help me whats wrong to go this way. I do not know how to avoid referencing to the libs in my B4A Project for example needed in my custom view code B4XCollections and StringUtils if I do so I got coding errors. Is there a way to tell the compiler not to include the referenced libs?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Please can you help me whats wrong to go this way.
Like I said, I don't know. I've only ever written Java libraries so I don't know how to make a library in B4A. It's something I would never do. I would either just use class modules in my programs and do it in a Java library if I can't do it in B4A.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Like I said, I don't know. I've only ever written Java libraries so I don't know how to make a library in B4A. It's something I would never do. I would either just use class modules in my programs and do it in a Java library if I can't do it in B4A.

Thank you again, may be an other collegue may have a solution. Erel or DonManfred for example. I am sorry but I testet some hours duringthe last days and read articles in the forum but found no other way to do as I've done.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Hey friends,
I found a solution for the problem. Do not use the 'compile to library ALT+5' Function. I do not now why but if you do you will get all the errors we talk about.

Instead of this create a zip File and rename the .zip extension into b4xlib. Put this file into the additional lib foldeer.
This compressed file may contain:
  • the FoldableMenu.bas file
  • a manually created manifest.txt file and
  • if needed a Files Folder with images or .bal files.

the manifest.txt is easy to create it contains only:
Version=2.5
version number.
Author=TechDoc G. Becker
version number.
B4J.DependsOn=jXUI, StringUtils
libraries used for B4J.
B4A.DependsOn=XUI, StringUtils
libraries used for B4A.
B4i.DependsOn=iXUI,StringUtils
libraries used for B4i


And to be honest the failure was up to me! The solution is described in the booklet 'b4x help custom views' that I didn't read carfully. Ashes on my head.:eek:
Hope with this info to help others not to run into the same trouble.
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Thank you Erel for the confirmation.
But as you see the paragraph about the custom views in the manual needs some maintenance it has no clear and no description in deep.
I think it would be good to make also very clear when to use the 'compile to libraray' and when to use 'b4xlibs' method.
The content of the manifest file is shown as an example but not explained.
 
Upvote 0
Top