Comments (23)
I was able to compile after upgrading to the latest version of Gradle available in Android Studio (7.0.2).
from jsch.
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.
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.
Unsupported class file major version 59
seem to be the key issue here.
from jsch.
I tried with Android Studio 4.1.3 as well. No change.
from jsch.
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.
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.
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.
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.
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.
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.
android.jetifier.blacklist = ...
Android Studio tells me that this option is not supported anymore.
from jsch.
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.
ssh-ed25519 support would be awesome. Would it be possible to integrate the code into jsch as a fallback mechanism?
from jsch.
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.
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.
Wouldn't support for Bouncy Castle be a possibility for jsch?
from jsch.
So is everything working for you now with newer versions of Gradle & Android Studio?
Thanks,
Jeremy
from jsch.
Well, I have switched org.connectbot:sshlib, since I was not able to resolve the issue.
from jsch.
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.
This is excellent news to hear! I am glad it is working for you now.
Thanks,
Jeremy
from jsch.
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.
@norrisjeremy thank you!
from jsch.
Related Issues (20)
- how to write part of sftp file with ChannelSftp HOT 1
- A strange bug when use InPutStream and OutPutStream
- FATAL: Bad packet length 604 HOT 1
- ChannelSftp.put() throws SftpException on some Android devices HOT 1
- sftp server die thread blocking during sftp ls execution HOT 4
- Prevent algorithm from known_host entry added to server host key list HOT 4
- How do I enable ssh-rsa (RSA/SHA1) in the latest version? HOT 1
- Next release plans HOT 6
- Scala compilation issue HOT 1
- "Could not connect to server" dependend on Jsch version and FTP key HOT 1
- ConnectTimeout from ssh-config read as ms instead of seconds? HOT 1
- Invalid PrivateKey
- Parsing malformed RSA key can try to allocate huge amount of memory HOT 1
- OpenSSHConfig.parse does not handle negated patterns as specified in ssh_config(5)
- Random null pointer exception HOT 3
- info required for compatible version with openjdk21 HOT 1
- List of ciphers, kex, DH, .... HOT 4
- Can it support SM2 SM4? HOT 2
- NullPointerException in JSch Session.connect() while connecting to Cisco IOS switch HOT 6
- Regarding No Such Method in bouncycastle HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsch.