using intellij-markdown in kotlin android project - android

I wanted to use intellij-markdown in one android kotlin project - but it does not survive the java roundtrip. Now I am searching for the least painful way to deal with this problem and hence ask here - perhaps someone faced the same problem. All solutions I have in mind currently are not really nice as they all diverge from upstream.
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Error:1 error; aborting
Error:Execution failed for task ':android:transformClassesWithDexForProdWithFirebaseDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/home/ligi/.gradle/caches/modules-2/files-2.1/org.jetbrains/markdown/0.1.23/f02dce4ef95be9f24a6ea59de2c187f597befb70/markdown-0.1.23.jar' to '/home/ligi/git/SurvivalManual/android/build/intermediates/transforms/dex/prodWithFirebase/debug/folders/1000/10/markdown-0.1.23_4afcc7019db1f3375984c600cc493df386228117'

Related

Android gradle build failed with error No matching variant

Facing this error while building the Android application
* What went wrong:
Execution failed for task ':app:mergeExtDexCiDebug'.
> Could not resolve all files for configuration ':app:ciDebugRuntimeClasspath'.
> Failed to transform mypkg:mylib-1.0.0.aar (mypkg:mylib:1.0.0) to match attributes {
artifactType=android-dex,
asm-transformed-variant=NONE,
dexing-enable-desugaring=true,
dexing-is-debuggable=true,
dexing-min-sdk=21,
org.gradle.category=library,
org.gradle.dependency.bundling=external,
org.gradle.libraryelements=aar,
org.gradle.status=integration,
org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /Users/xxx/.gradle/caches/transforms-3/49baf52f7ba8b21fe69d66f95b8d5255/transformed/jetified-mylib-1.0.0-runtime.jar.
> Error while dexing.
Using Gradle 7.5.1 and AGP version is 7.3.0-beta05 (tried earlier ones too). Android Studio version Android Studio Chipmunk | 2021.2.1 Patch 2.
As far as possible, I have verified I am using
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
Still, it is complaining about Java 8 incompatibility. Any idea how I can find if any of the dependencies is using Java 8 and if that's even a problem?
Looking into the logs (before this error is shown), I found another error message like
Compilation of classes ... requires its nest mates ... (unavailable) to be on program or class path.
Then it occurred that one of the SDKs I used cannot be upgraded to Java 11 and has to be Java 8. (I was trying to upgrade my current SDK as well as the dependent SDK to Java 11 and Gradle7). So downgrading just the Java version (11 back to 8) helped. Gradle/AGP version had no impact.
On a related note, this specific error message may be fixed in the upcoming Gradle release according to https://developer.android.com/studio/releases/fixed-bugs/studio/2021.3.1#android-studio-dolphin-canary-1-2021.3.1.1.

Android Gradle plugin 3.0.1 - Error converting bytecode to dex

Upgrading from Android Gradle 2.3.3 to 3.0.1 I was getting the following build error:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/common/base/internal/Finalizer;
This appeared to be an issue with Guava being included as an implementation, by my app; unit tests (Robolectric) and Instrumented Tests.
I resolved this build error by excluding Guava from Robolectric:
testImplementation ("org.robolectric:robolectric:$rootProject.ext.roboelectricVersion") {
exclude group: 'com.google.guava'
}
And for Instrumented tests, if I set the minSdkVersion to 21 it would resolve this build error there, via:
minSdkVersion 19
// Gradle plugin 3.0.1 broke instrumented tests with error: "Multiple dex files define ...Finalizer". Setting minSdkVersion = 21 clears this error
gradle.startParameter.taskNames.find {
if (it.contains("AndroidTest")) {
minSdkVersion 21
}
}
However, when I run a build for a device < 21, then I still get the build error.
So, the issue appears to be with Guava with Multidex support prior to Android 5.0.
Anyone else experiencing this issue and/or have suggestions for working around it?
Ok, the issue did seem to be with Guava. Taking a guess that it is the size of that library and the build having an issue with fitting it in the main DEX (the dex required for loading and initializing the app).
I switched out Guava for this lightweight Stream library and was able to build successfully for all devices.

transformClassesWithDexForDebug using IndoorAtlas Library

I try to use IndoorAtlas Android SDK example. I follow this guide.
But when I try to run it i get this error:
Error:Uncaught translation error: com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object[] using a local variable of type com.indooratlas.android.sdk.IAGeofenceRequest. This is symptomatic of .class transformation tools that ignore local variable information.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/xxx/AndroidStudioProjects/IndoorLocalization/app/libs/indooratlas-android-sdk-2.5.1.jar' to '/Users/xxx/AndroidStudioProjects/IndoorLocalization/app/build/intermediates/transforms/dex/debug/folders/1000/10/indooratlas-android-sdk-2.5.1_dbe918a8d06cf55c975257e4802cd6d4f4f48ea4'
How can i solve this issue?
IndoorAtlas Android SDK 2.5.1 had a bug with proguard opimizations. Use the newer 2.5.2 version which has this bug fixed. Version 2.5.2 can be used by specifying
dependencies {
...
compile 'com.indooratlas.android:indooratlas-android-sdk:2.5.2'
...
}
in your applications build.gradle file.

Android Studio Module/Dependency JDBC Issues

I am trying to setup a JDBC jar for my android studio project. I am currently getting an error when trying to launch the application due to the Module/Dependency I added.
Stack Trace
Error:Gradle: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
I tried following the steps in the trace and modifying the build.gradle file but could not resolve the issue. I am not sure if I need to uninstall and reinstall the module and set the compiler to 1.7 in the process or if I can even do that.
To get it to work you'll need a Java 7 compiled jar. See: Is it possible to use Java 8 for Android development?.
Additionally not sure why you are trying to include a JDBC driver into Android app, but recommend reading this: JDBC vs Web Service for Android

Error converting bytecode to dex - Multiple dex files define

I work on an android application, but during build process I have got following error message. Android Studio has updated Gradle version, maybe this causes errors.
Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: 0Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
I have tried to use code after project clean and rebuild in build.gradle.
dexOptions {
preDexLibraries = false
}
After that I get much more error messages, like this.
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorCompatHelper;

Categories

Resources