Android Question How can I change the generated Java code?

wonder

Expert
Licensed User
Longtime User
In B4x (B4A / B4J), I would like to apply some of my own optimizations. In order to do so, I'd like to use a command line find and replace tool (similar to sed in linux).

So far, I have no problems altering the generated Java file from the command line, but I'm unable to do so using the #CustomBuildAction attribute.

So, my question is, how can I alter the B4x generated Java code, just before it gets compiled?

EDIT: I want to alter the Java code BEFORE it gets compiled, not after.
 
Last edited:

wonder

Expert
Licensed User
Longtime User
Step 6 happens after Java compilation... not before.
step id can be one of the following:
1 - Before the compiler cleans the objects folder (it happens after the code is parsed).
2 - Before R.java file is generated.
3 - Before the package is signed (the APK file at this point is: bin\temp.ap_).
4 - Before the APK is installed.
5 - After the APK is installed.
6 (new in v5.01) - After Java compilation.

Ok, so after reading what I wrote once again, I see that I might not have explained myself properly in the first post, so I'll try again...

To my understanding, B4x parses the user code (BASIC style) into B4x Java code. Once the parsing is complete, the Java code is compiled. Correct?

Capture.PNG


I would like to know, is is possible to introduce changes to the parsed Java code, right before it gets compiled?
 
Last edited:
Upvote 0
Top