mwiede/jsch

Android: DexMerge Failed

Opened this issue · 10 comments

I am adding the lib to my android project which has following gradle configuration:
build:gradle:7.4.2
But when I build the project I get following error

`> Task :app:mergeDexDebug FAILED
AGPBI: {"kind":"error","text":"java.lang.NullPointerException","sources":[{"file":"/Users/asad/.gradle/caches/modules-2/files-2.1/com.github.mwiede/jsch/0.2.16/18efa961263b774dc98ea267ab57f8aeaa4152b1/jsch-0.2.16.jar"}],"tool":"D8"}

Execution failed for task ':app:mergeDexDebug'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Failed to transform jsch-0.2.16.jar (com.github.mwiede:jsch:0.2.16) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=19, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /Users/asad/.gradle/caches/modules-2/files-2.1/com.github.mwiede/jsch/0.2.16/18efa961263b774dc98ea267ab57f8aeaa4152b1/jsch-0.2.16.jar.
> Error while dexing.`

I have setup an Android project and did not get this error.

Can you please give more information about source and target java version, JDK, etc.

Did you try to clear cache?

@mwiede
I created a new project and it is on gradle 8 it's working fine.
But for my existing project, with gradle 7 JSch the versions later than 0.2.12 are not working.
Here is my gradle:
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip
com.android.tools.build:gradle:7.4.2
java version: jbr-17 JetBrains Runtime version 17.0.6

I know little about Android development and Gradle, but it sounds to me like if Gradle 8.x works and 7.x doesn't, then perhaps you should be using 8.x?

Is there any specific changes after 0.2.12 that gradle 7 does not support? I think JSch has nothing to do with gradle. It has dependency with Java version and I am using Java 17 which is OK.

I know little about Android development and Gradle, but it sounds to me like if Gradle 8.x works and 7.x doesn't, then perhaps you should be using 8.x?

Major gradle updates usually require major changes in gradle projects, especially on Android

I am having a similar issue on gradle 7, gonna use 0.2.12 until it's fixed. My project is too big and updating gradle would be painful.

I am having a similar issue on gradle 7, gonna use 0.2.12 until it's fixed. My project is too big and updating gradle would be painful.

It's unlikely that any "fix" for this will be coming from some future JSch release, as this is a Gradle problem, not a problem with JSch.

@asadqazi @IgeNiaI Have you tried gradle 7.6.4 ?

@wiedemam-VU nope, still fails