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

Upload error in the app in release mode. #168

Open
yurijdvornyk opened this issue May 18, 2021 · 3 comments
Open

Upload error in the app in release mode. #168

yurijdvornyk opened this issue May 18, 2021 · 3 comments
Labels
android Android-only issues

Comments

@yurijdvornyk
Copy link

I am trying to upload a file to S3 with a presigned URL.
Everything works fine in debug build, however when I run the app in release mode, I am getting the following error:

2021-05-18 15:51:06.931 16494-17980/? E/UploadWorker: exception encountered
    java.lang.RuntimeException: Missing type parameter.
        at b.b.c.M.a.<init>(:3)
        at com.bluechilli.flutteruploader.t.<init>(Unknown Source:0)
        at com.bluechilli.flutteruploader.UploadWorker.l(Unknown Source:112)
        at com.bluechilli.flutteruploader.UploadWorker.a(Unknown Source:0)
        at com.bluechilli.flutteruploader.k.run(Unknown Source:4)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)

2021-05-18 15:51:06.938 16494-16589/? I/WM-WorkerWrapper: Worker result FAILURE for Work [ id=645254f3-b9a7-4812-8f95-6e9a5fc16c6d, tags={ flutter_upload_task, com.bluechilli.flutteruploader.UploadWorker } ]

Then, I am getting 500 response (despite everything is fine, the URL is valid and I have full permissions to write to S3 bucket). What could cause such behavior?

flutter doctor -v:

[✓] Flutter (Channel stable, 2.0.2, on macOS 11.1 20C69 darwin-x64, locale en-GB)
    • Flutter version 2.0.2 at /Users/yurii.dvornyk/Documents/flutter
    • Framework revision 8962f6dc68 (10 weeks ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at <...>/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = <...>/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_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (3 available)
    • Pixel 3a (mobile)       • 93RAY0EM5W                • android-arm64  • Android 11 (API 30)
    • U — iPhone (2) (mobile) • 00008020-001145D40EC2002E • ios            • iOS 14.0.1
    • Chrome (web)            • chrome                    • web-javascript • Google Chrome 90.0.4430.212
@ened
Copy link
Collaborator

ened commented May 18, 2021

@yurijdvornyk which plugin version are you using?

@yurijdvornyk
Copy link
Author

@ened , I have to use 3.0.0-beta1 to be able to use it in the project with sounding null-safety.

@ened ened added the android Android-only issues label May 28, 2021
@cristik
Copy link

cristik commented Dec 14, 2024

Ran into the same issue, this Stackoverflow post has the fix for it.

Basically, add the following lines to android/app/proguard-rules.pro

-keep class com.google.gson.reflect.TypeToken
-keep class * extends com.google.gson.reflect.TypeToken
-keep public class * implements java.lang.reflect.Type

Seems that when the app is shrunk (which happens when building for Release), some reflection details are stripped away, causing the issue. An alternative would be to use -dontshrink in the proguard-rules.pro file, however I think this is a more extreme approach.

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

No branches or pull requests

3 participants