Java Question com.android.dx.cf.code.SimException

DonManfred

Expert
Licensed User
Longtime User
I am building a Library for TapKey.
When i add one of the AAR references (#AdditionalJar) i get an Error when compiling.

B4A Version: 9.01.2
Java Version: 11
Parsing code. (0.00s)
Building folders structure. (0.02s)
Compiling code. (0.01s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.34s)
Compiling generated Java code. (1.75s)
Convert byte code - optimized dex. Error
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:696)
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:688)
... 4 more

I´ve attached the Files.

Effectively i am using only
B4X:
#AdditionalJar: Tapkey.MobileLib-1.15.12.0.aar

The source of the AAR is not available so i am forced to use the provided JARs and AARs.

Any idea what the problerm here is/how i could fix it?
 

Attachments

  • TK1.zip
    169.6 KB · Views: 557
  • TK2.zip
    376 KB · Views: 547

moster67

Expert
Licensed User
Longtime User
I don't understand much of the problem but it seems like when using the legacy dx tool, it produces the error you got:
B4X:
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

If you look at the build-gradle in the sample app of TapKey:

B4X:
android {
    compileSdkVersion 28
    buildToolsVersion = "28.0.3"
    defaultConfig {
        applicationId "net.tpky.demoapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        manifestPlaceholders = [auth0Domain: "", auth0Scheme: "https"]
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

they have set the sourceCompatibility and targetCompatibility to 1.8. From what I have read, by setting said Compatibility settings they are enabling another dx tool, namely the D8 Dexer tool.

You can read more about it here:
https://jakewharton.com/androids-java-8-support/

Maybe this can be resolved by setting the minSDK-version to 26 (which would exclude many older devices with older OS) or maybe Erel would need to change something in B4A's toolchain (which I guess is custom) when compiling.

Sorry that I cannot help.
 

DonManfred

Expert
Licensed User
Longtime User
Maybe this can be resolved by setting the minSDK-version to 26 (which would exclude many older devices with older OS) or maybe Erel would need to change something in B4A's toolchain (which I guess is custom) when compiling.
The aar can be found when directly accesing their maven repository.
I do not have the source for the AAR they provide. So i can not change any serttings and recreate a new AAR. Unfortunately :-(

I also tried to set the minsdk version in my Manifest but this does not help. I ran into the same compiling error.

So the problem is with their AAR-Files. I guess it is because they are using Lamda in the AAR too (as they are in the Example-Project).
 

DonManfred

Expert
Licensed User
Longtime User
or maybe Erel would need to change something in B4A's toolchain (which I guess is custom) when compiling.
I had a similar issue in the past. He announced it do be included in the next non bugfix version.
See here. Don´t know if the two issues are related.

But it will not help in this case as the device the lib should run on is using Android 7.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Download this jar: www.b4x.com/android/files/Tapkey2.jar

It was compiled with this command:
B4X:
"c:\Program Files\Java\jdk1.8.0_151\bin\java" -jar Desugar_deploy.jar --bootclasspath_entry="C:\android-sdk-windows9\platforms\android-28\android.jar" --input=Tapkey.jar --output=Tapkey2.jar --bootclasspath_entry="C:\Users\H\Documents\AdditionalLibs\B4A\gson-2.3.1.jar"
I will explain more when we see that it works.

This jar includes all the classes from the two zip files you've uploaded. This means that you need to delete classes.jar from inside the two aar files.
 

DonManfred

Expert
Licensed User
Longtime User
Quickly connected remotely to my PC and did the changes.
B4X:
#AdditionalJar: Tapkey.MobileLib-1.15.12.0.aar ' AAR without classes.jar
#AdditionalJar: TapKey2.jar

I can Compile now without any Error. Need to check with a Device connected later though. But looks good.
With the original AAR it stops when compiling.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I can compile the app and also was able to setup the manifest correctly. I got first methods working.

But when i try to login then there are methods called which depends on AndroidX Support Library and other AndroidX dependencies. I end up in new problems for which i will create a new Thread.
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Download this jar: www.b4x.com/android/files/Tapkey2.jar

It was compiled with this command:
B4X:
"c:\Program Files\Java\jdk1.8.0_151\bin\java" -jar Desugar_deploy.jar --bootclasspath_entry="C:\android-sdk-windows9\platforms\android-28\android.jar" --input=Tapkey.jar --output=Tapkey2.jar --bootclasspath_entry="C:\Users\H\Documents\AdditionalLibs\B4A\gson-2.3.1.jar"
I will explain more when we see that it works.

This jar includes all the classes from the two zip files you've uploaded. This means that you need to delete classes.jar from inside the two aar files.

I got the same issue here with another library, but I have the source code.
Whats the best thing to resolve this? change dexer? compatibility on java source code?

B4X:
B4A Version: 9.01.2
Java Version: 8
Parsing code.    (0.00s)
Building folders structure.    (0.09s)
Compiling code.    (0.05s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
Generating R file.    (0.00s)
Compiling debugger engine code.    (0.00s)
Compiling generated Java code.    (0.02s)
Convert byte code - optimized dex.    Error
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
3 errors; aborting
 
Top