Giter VIP home page Giter VIP logo

Comments (23)

jda258 avatar jda258 commented on June 28, 2024 1

I was able to compile after upgrading to the latest version of Gradle available in Android Studio (7.0.2).

from jsch.

mendhak avatar mendhak commented on June 28, 2024 1

FWIW, and for future searchers.
I was running into "AlgorithmParameters EC implementation not found" with version 0.1.58.
And trying to use 0.1.67 resulted in "Unsupported class file major version 59"

I had to update the Android Gradle Plugin to 7.0.2

classpath 'com.android.tools.build:gradle:7.0.2'

And the Gradle tool to 7.0.2

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

And ensure that the project's JDK was set to at least version 11.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

I tried to create a new dummy project in Android Studio 4.1.1 and added only:

implementation 'com.github.mwiede:jsch:0.1.62'

No useAndroidX or enableJetifier are set like I did before.

This gives me:

Execution failed for task ':app:mergeDebugJavaResource'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform jsch-0.1.62.jar (com.github.mwiede:jsch:0.1.62) to match attributes {artifactType=android-java-res, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /home/mwarning/.gradle/caches/modules-2/files-2.1/com.github.mwiede/jsch/0.1.62/de4b21c9c2d40481ec19644c16c66fc7a44027c8/jsch-0.1.62.jar.
         > Failed to transform '/home/mwarning/.gradle/caches/modules-2/files-2.1/com.github.mwiede/jsch/0.1.62/de4b21c9c2d40481ec19644c16c66fc7a44027c8/jsch-0.1.62.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
           Suggestions:
            - Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
            - If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).

from jsch.

mwarning avatar mwarning commented on June 28, 2024

Unsupported class file major version 59 seem to be the key issue here.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

I tried with Android Studio 4.1.3 as well. No change.

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

JSch is a multi-release jar that contains some Java 15 classes (class file major version 59) for ssh-ed448 / ssh-ed25519 support.
I'm not familiar with Android development, but the messages you provided seem to indicate it doesn't cope with the optional Java 15 classes included with the jar. I'm not sure if there is a way to configure it to ignore the Java 15 classes in the jar (they are under META-INF/versions/15/).

from jsch.

mwarning avatar mwarning commented on June 28, 2024

Thank your for the additional information!

Android Studio has only Java 8 (and 10) available. I don't know how to work around this. :/

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

FYI, there are also some optional Java 11 classes present (class file major version 55) also contained in the jar for curve25519-sha256 / curve448-sha512 & chacha20-poly1305 support; they are under META-INF/versions/11/.

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

As I mentioned, am I not at all familiar with Android development. But briefly reading online, it seems that this JetifyTransform build step is used to help transform some sort of Android specific support library references?
If so, perhaps it isn't needed for JSch, since it is a pure Java library that doesn't use Android specific support libraries?
Is it possible to configure your Gradle build to exclude running the JetifyTransform step on the JSch jar?

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

If I'm reading the link below correctly, it seems it's possible to exclude certain libraries in your gradle.properties?

https://stackoverflow.com/a/53869014

from jsch.

mwarning avatar mwarning commented on June 28, 2024

I tested with a newly created app in Android Studio and added this line to app/build.gradle:

implementation 'com.github.mwiede:jsch:0.1.62'

This works if I check Use legacy android.support libraries.. But a warning message tells me that this is only supported until Android 10 (Q).

If I do not check this option (default setting), then I get this Unsupported class file major version 59 error.

My app also targets Android 11 and I switched to AndroidX a few releases ago. :/

from jsch.

mwarning avatar mwarning commented on June 28, 2024

@norrisjeremy

android.jetifier.blacklist = ...

Android Studio tells me that this option is not supported anymore.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

With a default android project (Use legacy android.support libraries. is disabled), compiling works until com.github.mwiede:jsch:0.1.60. With 0.1.61, I get the Unsupported class file major version 59 error.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

ssh-ed25519 support would be awesome. Would it be possible to integrate the code into jsch as a fallback mechanism?

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

I'm not sure what else to do if Android removed the ability to exclude running the JetifyTransform on specific libraries. You may need to inquire on some Android support forums to see if there is some other way to exclude the JSch jar from this step?

As for the ssh-ed25519 support: the code in JSch to support it relies upon JEP 339, which was added into Java 15. It's not feasible to extract all that code out of OpenJDK and integrate it directly into JSch.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

I got this line in gradle.properties working:

android.jetifier.blacklist=jsch

But, while the app now compiles using jsch 0.1.62 , I get exceptions like java.lang.ClassNotFoundException: com.jcraft.jsch.jce.KeyPairGenEdDSA.

Sorry, but I have to look for a different ssh lib for my use case. Thanks a lot for the support.

from jsch.

mwarning avatar mwarning commented on June 28, 2024

Wouldn't support for Bouncy Castle be a possibility for jsch?

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

Hi @mwarning & @jda258,

So is everything working for you now with newer versions of Gradle & Android Studio?

Thanks,
Jeremy

from jsch.

mwarning avatar mwarning commented on June 28, 2024

Well, I have switched org.connectbot:sshlib, since I was not able to resolve the issue.

from jsch.

jda258 avatar jda258 commented on June 28, 2024

Hi @norrisjeremy,

It is working well for me. I have migrated to this fork for the Flutter plugin I manage: https://pub.dev/packages/ssh2

I'm also using it in production for an Android app. Thanks so much for your work on this fork!

Thanks,
Josh

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

@jda258,

This is excellent news to hear! I am glad it is working for you now.

Thanks,
Jeremy

from jsch.

norrisjeremy avatar norrisjeremy commented on June 28, 2024

Wouldn't support for Bouncy Castle be a possibility for jsch?

Hi @mwarning,
FYI, in the new 0.1.66 release we added Bouncy Castle implementations for various algorithms that were only supported in newer Java versions. So you should be able to make use of them now with older Java releases by simply adding the Bouncy Castle library to your application(s).

Thanks,
Jeremy

from jsch.

mwarning avatar mwarning commented on June 28, 2024

@norrisjeremy thank you!

from jsch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.