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

Discussion in 'Libraries developers questions' started by DonManfred, May 12, 2019.

  1. DonManfred

    DonManfred Expert Licensed User

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

    I´ve attached the Files.

    Effectively i am using only
    Code:
    #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?
     

    Attached Files:

    • TK1.zip
      File size:
      169.6 KB
      Views:
      31
    • TK2.zip
      File size:
      376 KB
      Views:
      31
  2. moster67

    moster67 Expert Licensed 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:
    Code:
    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:

    Code:
    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 likes this.
  3. DonManfred

    DonManfred Expert Licensed User

    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).
     
  4. DonManfred

    DonManfred Expert Licensed User

    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.
     
  5. moster67

    moster67 Expert Licensed User

    I think they are related. I guess we will find out when next version is released.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Download this jar: www.b4x.com/android/files/Tapkey2.jar

    It was compiled with this command:
    Code:
    "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.
     
  7. DonManfred

    DonManfred Expert Licensed User

    Thank you. I´ll check later when i am at Home and post the result.
     
  8. DonManfred

    DonManfred Expert Licensed User

    Quickly connected remotely to my PC and did the changes.
    Code:
    #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: May 13, 2019
    Erel likes this.
  9. DonManfred

    DonManfred Expert Licensed 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.
     
  10. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

    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?

    Code:
    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
     
  11. DonManfred

    DonManfred Expert Licensed User

  12. Alberto Iglesias

    Alberto Iglesias Well-Known Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice