flutter_ssh
flutter_ssh copied to clipboard
Error after upgraded to Flutter 1.12
For some reason, it does work when I'm debugging; but after I build the production APK, it throws this error:
PlatformException(connection_failure, java.lang.ClassNotFoundException: com.jcraft.jsch.jce.Random, null)
Flutter Doctor
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.1 19B88, locale en-US)
• Flutter version 1.12.13+hotfix.5 at /Users/juanm04/dev/tools/flutter
• Framework revision 27321ebbad (6 days ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/juanm04/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /Users/juanm04/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage
on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[!] IntelliJ IDEA Ultimate Edition (version 2019.2.4)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] VS Code (version 1.41.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.7.1
[✓] Connected device (1 available)
• ONEPLUS A6013 • 192.168.86.123:5555 • android-arm64 • Android 10 (API 29)
Had the same issues this solved it for me:
- Run flutter build apk --release
- Ignore all warning like ssh uses unsafe operations
- Open the android folder in Android Studio
- Let the indexing and the gradle sync process finish
- Change the Build Variants to release
- Then: Build / Generate Signed Bundle/APK
@thomashuettmaier Thanks, that worked for me! How can I do it with flutter build apk --split-per-abi
?
I also encountered this issue. The error log shows:
/flutter/.pub-cache/hosted/pub.dartlang.org/ssh-0.0.5/android/src/main/java/sq/flutter/ssh/SshPlugin.java:404: warning: [unchecked] unchecked conversion
Vector<LsEntry> files = channelSftp.ls(args.get("path").toString());
^
required: Vector<ChannelSftp.LsEntry>
found: Vector
1 warning
* What went wrong:
Execution failed for task ':ssh:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
myapp/build/ssh/intermediates/res/merged/release/values/values.xml:236: error: resource android:attr/fontVariationSettings not found.
myapp/build/ssh/intermediates/res/merged/release/values/values.xml:237: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Anyone has ideas on it?
@thomashuettmaier Thanks, that worked for me! How can I do it with
flutter build apk --split-per-abi
?
Sorry I don't have an idea how to do that.
I also encountered this issue. The error log shows:
/flutter/.pub-cache/hosted/pub.dartlang.org/ssh-0.0.5/android/src/main/java/sq/flutter/ssh/SshPlugin.java:404: warning: [unchecked] unchecked conversion Vector<LsEntry> files = channelSftp.ls(args.get("path").toString()); ^ required: Vector<ChannelSftp.LsEntry> found: Vector 1 warning * What went wrong: Execution failed for task ':ssh:verifyReleaseResources'. > java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed myapp/build/ssh/intermediates/res/merged/release/values/values.xml:236: error: resource android:attr/fontVariationSettings not found. myapp/build/ssh/intermediates/res/merged/release/values/values.xml:237: error: resource android:attr/ttcIndex not found. error: failed linking references.
Anyone has ideas on it?
It says :ssh:verifyReleaseResources
, so maybe there is an error when building the APK
Any progress on this issue ? The workaround doesn't work for me (or maybe I didn't fully understand it)
I just set API level ≥ 21. My app simply doesn't support Android 4.4 now
I just set API level ≥ 21. My app simply doesn't support Android 4.4 now
targetSdkVersion is 28, and minSdkVersion is 18, but I'm testing on Android 9.0, so I don't see the link that this issue may have with minSdkVersion ?
I did that, worked for a while weirdly, and then I stopped using this package
I did that, worked for a while weirdly, and then I stopped using this package
You found an alternative ?
No to flutter_ssh, I just found an alternative to solve my particular problem
I managed to solve the crash in the production APK by adding the --no-shrink flag to the build:
flutter build apk --no-shrink --split-per-abi
My only guess is that the code shrinker thinks the library is not in use and deletes it Hope it helps
The workaround also works for me with appbundle
flutter build apk --no-shrink
Any idea how to really fix this ?
com.jcraft.jsch.jce.Random
i have same problem,but i solved it
first edit android/app/build.gradle enable minifyEnabled and useProguard
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
then create android/app/proguard-rules.pro and write class com.jcraft.,my document like this
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.jcraft.** { *; }
Any progress on this issue ? The workaround doesn't work for me (or maybe I didn't fully understand it)
https://github.com/shaqian/flutter_ssh/issues/27#issuecomment-599180850