Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after upgraded to Flutter 1.12 #27

Open
JuanM04 opened this issue Dec 16, 2019 · 16 comments
Open

Error after upgraded to Flutter 1.12 #27

JuanM04 opened this issue Dec 16, 2019 · 16 comments

Comments

@JuanM04
Copy link

JuanM04 commented Dec 16, 2019

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)
@thomashuettmaier
Copy link

thomashuettmaier commented Dec 17, 2019

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

@JuanM04
Copy link
Author

JuanM04 commented Dec 17, 2019

@thomashuettmaier Thanks, that worked for me! How can I do it with flutter build apk --split-per-abi?

@tc14077
Copy link

tc14077 commented Dec 19, 2019

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
Copy link

@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.

@JuanM04
Copy link
Author

JuanM04 commented Dec 19, 2019

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

@Nico04
Copy link

Nico04 commented Jan 23, 2020

Any progress on this issue ?
The workaround doesn't work for me (or maybe I didn't fully understand it)

@JuanM04
Copy link
Author

JuanM04 commented Jan 25, 2020

I just set API level ≥ 21. My app simply doesn't support Android 4.4 now

@Nico04
Copy link

Nico04 commented Jan 25, 2020

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 ?

@JuanM04
Copy link
Author

JuanM04 commented Jan 25, 2020

I did that, worked for a while weirdly, and then I stopped using this package

@Nico04
Copy link

Nico04 commented Jan 26, 2020

I did that, worked for a while weirdly, and then I stopped using this package

You found an alternative ?

@JuanM04
Copy link
Author

JuanM04 commented Jan 26, 2020

No to flutter_ssh, I just found an alternative to solve my particular problem

@Diviloper
Copy link

Diviloper commented Jan 31, 2020

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

@Nico04
Copy link

Nico04 commented Feb 17, 2020

The workaround also works for me with appbundle
flutter build apk --no-shrink

Any idea how to really fix this ?

@zuiwuchang
Copy link

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.**  { *; }

@zuiwuchang
Copy link

Any progress on this issue ?
The workaround doesn't work for me (or maybe I didn't fully understand it)

#27 (comment)

@camelChief
Copy link

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.**  { *; }

If anyone is still struggling with this issue, and this work around didn't fix it for you, try creating the proguard-rules.pro file as stated, but don't edit your build.gradle file. For whatever reason, editing the build.gradle file produced errors for me. While digging, I found this answer https://stackoverflow.com/a/70268820 which states that useProguard is obsolete and will cause Groovy to throw errors. The Android docs https://developer.android.com/studio/build/shrink-code#configuration-files seem to imply that you can still define ProGuard rules to prevent files being removed. So I removed the code from build.gradle that was causing the error and it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants