Blasanka / aws_s3_plugin

This is a plugin created for file upload to AWS S3
Other
10 stars 13 forks source link

PlatformException with release version #8

Closed ghost closed 4 years ago

ghost commented 4 years ago

I'm seeing the following error in logcat when testing a release version of my APK. Everything works fine when the APK is a debug version.

06-15 14:27:53.506 10592-10621/? E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'b.a.y.b.a.i b.a.y.b.a.q.a(java.lang.String, java.lang.String, java.io.File, b.a.b0.c.g.e)' on a null object reference, null)
                                            #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)
                                            #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156)
                                            <asynchronous myapp>
                                            #2      AwsS3.uploadFile (package:aws_s3/aws_s3.dart:43)
                                            <asynchronous myapp>
                                            #3      RecordPageState.uploadVideo (package:myapp/main.dart:474)
                                            <asynchronous myapp>
                                            #4      RecordPageState.onUploadButtonPressed (package:myapp/main.dart:380)
                                            <asynchronous myapp>

Flutter version: v1.17.0 aws_s3 version: ^0.1.1+hotfix.5 Device: OnePlus 6, Android 10

Has anyone else experienced this? Happy to provide more information/code if necessary.

Usage:

Future<void> uploadVideo() async {
    final Directory extDir = await getApplicationDocumentsDirectory();
    final String filePath = '${extDir.path}/xxx.mp4';

    AwsS3 awsS3 = AwsS3(
      awsFolderPath: "xxx",
      file: File(filePath),
      fileNameWithExt: "xxx.mp4",
      poolId: "xxx",
      region: Regions.EU_WEST_1,
      bucketName: "xxx"
    );

      String result = await awsS3.uploadFile;
      debugPrint(result);
  }
Blasanka commented 4 years ago

@iainco Please note that Flutter uses proguard,

You have to add / update your proguard rule file to not to exclude AWS S3 files. This is recommended from official AWS S3 android also. Go to this link and copy paste to your proguard rule file which is located in flutter root directory -> android -> app directory.

You can refer this SO Q&A also