Android Question B4A 3.0 Strange Compile Bug

ralphie911

Member
Licensed User
Longtime User
B4X:
package ipt.zoomtan.com;

import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;
I have a fairly involved application that all of a sudden no longer compiles into Release mode. However, it compile with no errors and also executes without errors when compiling with Debug(rapid) mode.

The error that is created is the following:

B4X:
Parsing code.                          0.07
Compiling code.                        0.76
Compiling layouts code.                0.03
Generating R file.                      0.23
Compiling generated Java code.          1.92
Convert byte code - optimized dex.      Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/json/JSONException;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:490)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:191)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:123)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:422)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
    at com.android.dx.command.dexer.Main.run(Main.java:209)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)
1 error; aborting
    Optimized dexer failed. Switching to Standard dexer.

The main.java file has the following import statements. I hope this helps:

B4X:
import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

I have no idea where to begin to troubleshoot this issue.

Can anyone shed some light onto this?
 
Last edited:

ralphie911

Member
Licensed User
Longtime User
Yes I had the same problem with HTTPUtils but this code was working earlier this morning. I don't recall making any changes. I even restored the b4a code from an earlier backup with the same result.

Thanks for helping
Ralph
 
Upvote 0

ralphie911

Member
Licensed User
Longtime User
I did send the project this morning. I do have a bit more info with this problem: When I disable the JSON code on lines 380, 381 and 385 B4A compiles again of course the app crashes later as the JASON code is required. The strange part is, this code has not changed in at least 6 months. I replaced the JSON library files from an older backup with no change.

Any ideas? I am really stumped.
 
Upvote 0

ralphie911

Member
Licensed User
Longtime User
I do have a solution, but I am still befuddled. I compiled the project using B4A version 2.71 instead of version 3.0 and everything works just fine. So I will stick to it for now unless you have any other ideas.

Thanks again
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There were two problems. AudioSerial.jar includes an AndroidManifest.xml file inside. This is not needed and causes problems during the signing.

The problem you see is related to UVRelay library. It includes JSON classes inside. These classes are part of Android and should not be included in the jar.

You can fix both issues by opening the jar file with a program such as 7zip and remove the problematic classes.
 
Upvote 0
Top