Android Question Error sdk-version>=26

Peekay

Active Member
Licensed User
Longtime User
I get these errors when I run my B4A project:

Compiling generated Java code. (0.03s)
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)
7 errors; aborting

I think the error is in the manifest file which has the following code:
Manifest:
AddManifestText(<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/><supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>)
AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false" />)
AddManifestText(<uses-permission
 android:name="android.permission.WRITE_EXTERNAL_STORAGE"
 android:maxSdkVersion="19" />)
AddManifestText(<uses-permission android:name="android.permission.SEND_SMS" />)
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_FINE_LOCATION")
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.VIBRATE")
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.permission.READ_CONTACTS")
AddPermission("android.permission.READ_PROFILE")
AddPermission("android.hardware.camera")
AddPermission("android.permission.ACCESS_NETWORK_STATE")
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
AddPermission("android.permission.ACCESS_WIFI_STATE")
AddPermission("com.google.android.providers.gsf.permission.READ_GSERVICES")
AddPermission("android.permission.BLUETOOTH")
AddPermission("android.permission.GET_ACCOUNTS")
AddPermission("android.permission.SEND_SMS")
AddPermission("android.permission.READ_SMS")
AddPermission("android.permission.WRITE_SMS")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission("android.permission.WAKE_LOCK")
AddPermission("android.permission.DEVICE_POWER")
AddPermission("android.permission.GET_ACCOUNTS")
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)
AddPermission("android.permission.READ_PHONE_STATE")

Any help will be appreciated.

Thanks
PK
 

Peekay

Active Member
Licensed User
Longtime User
Thanks JohnC,
But I am not even using a media player or video player in my app.
I took Erel's advice when the errors stated in the introduction of this thread came up when I compiled it, and this was his advice that I should desugar.
Now I doubt that advice and suspect that something else must be wrong.
However, I think my best way out is to start the app on a clean sheet and see what happens.
Thanks for your patience. I appreciate.

PK
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, I understand where you are coming from because the page that Erel pointed to starts off with "Some of the new Android libraries use Java 8 features. Android doesn't natively support those features so they must be removed (desugared) at some point."

So, basically you need to find out what lib is causing this compile error - probably by unselecting one lib at a time and remarking out it's related code in the project.
 
Upvote 0

Peekay

Active Member
Licensed User
Longtime User
Here are some clues I have found, but I do not understand them:

The desugar situation is complicated. Android Gradle Plugin (used in Android Studio) once incorporated desugar_deploy.jar to deal with desugaring. Now Google introduced d8 and quickly abandoned standalone desugar tool. Since Google has already removed desugar_deploy from Android Gradle Plugin setup, we will have to do the same.

After hours of struggling, I solved it by including the following within app/build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

PK
 
Upvote 0

Peekay

Active Member
Licensed User
Longtime User
I have established that the cause of the error is the dexer. Opening another thread for that.
PK
 
Upvote 0
Top