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

Some plugins breaks on release mode on Android #78625

Closed
ekasetiawans opened this issue Mar 19, 2021 · 38 comments · Fixed by flutter/plugins#3746
Closed

Some plugins breaks on release mode on Android #78625

ekasetiawans opened this issue Mar 19, 2021 · 38 comments · Fixed by flutter/plugins#3746
Assignees
Labels
a: release Challenges faced when attempting to productionize an app c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. found in release: 2.0 Found to occur in 2.0 found in release: 2.1 Found to occur in 2.1 has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression package flutter/packages repository. See also p: labels. platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@ekasetiawans
Copy link

Steps to Reproduce

  1. Create a new application project
  2. Add package_info: ^2.0.0
  3. Use package_info in app, for example show your package name
  4. Run with flutter run --release
  5. package name shown
  6. Add image_picker : ^0.7.3
  7. Re-run with --release mode.
  8. package name not shown

Here is the sample project:
https://github.com/ekasetiawans/imagepickerbug

Expected results:

Actual results:

Logs
Last login: Fri Mar 19 21:56:10 on ttys025
ekasetiawans@MacBookPro ~ % flutter doctor -v
[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale
    en-ID)
    • Flutter version 2.0.2 at /Users/ekasetiawans/Development/flutter-stable
    • Framework revision 8962f6dc68 (8 days 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.3)
    • Android SDK at /Users/ekasetiawans/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • 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.4, Build version 12D4e
    • 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.54.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (3 available)
    • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64    •
      Android 11 (API 30) (emulator)
    • macOS (desktop)                  • macos         • darwin-x64     • macOS
      11.2.3 20D91 darwin-x64
    • Chrome (web)                     • chrome        • web-javascript • Google
      Chrome 87.0.4280.88

• No issues found!
ekasetiawans@MacBookPro ~ % 

@ekasetiawans
Copy link
Author

this only happens in android

@iapicca
Copy link
Contributor

iapicca commented Mar 19, 2021

@ekasetiawans
I confirm an unexpected behavior on master as well, tested on physical device

code sample
/// `https://gist.github.com/iapicca/cf6cd91851063c8718fb1e2ffe92f1d3`

import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:image_picker/image_picker.dart';

Future<String?> getVersion() async {
  print('********** getting version');
  try {
    final info = await PackageInfo.fromPlatform();
    return info.version;
  } on Exception catch (e, s) {
    print('########## EXCEPTION: $e\n########## STACKTRACE: $s');
  }
}

Future<Image?> pickImage() async {
  print('********** picking image');
  try {
    final file = await ImagePicker().getImage(
      source: ImageSource.gallery,
    );
    if (file != null) {
      return Image.file(File(file.path));
    }
    print('********** did not pick any image');
  } on Exception catch (e, s) {
    print('########## EXCEPTION: $e\n########## STACKTRACE: $s');
  }
}

final version = ValueNotifier<String?>(null);

final image = ValueNotifier<Image?>(null);

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
          body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          ListTile(
            title: ValueListenableBuilder<String?>(
              valueListenable: version,
              child: const Text('empty'),
              builder: (context, value, child) =>
                  value != null ? Text(value) : child!,
            ),
            trailing: ElevatedButton(
              child: version.value == null
                  ? const Icon(Icons.refresh)
                  : const Icon(Icons.delete),
              onPressed: () async => version.value == null
                  ? version.value = await getVersion()
                  : version.value = null,
            ),
          ),
          ListTile(
            title: ValueListenableBuilder<Image?>(
              valueListenable: image,
              child: const Text('empty'),
              builder: (context, value, child) => value ?? child!,
            ),
            trailing: ElevatedButton(
              child: image.value == null
                  ? const Icon(Icons.image)
                  : const Icon(Icons.delete),
              onPressed: () async => image.value == null
                  ? image.value = await pickImage()
                  : image.value = null,
            ),
          ),
        ],
      )),
    ),
  );
}

logs
[        ] BUILD SUCCESSFUL in 41s
[        ] 117 actionable tasks: 103 executed, 14 up-to-date
[ +362 ms] Running Gradle task 'assembleRelease'... (completed in 41.8s)
[  +34 ms] calculateSha: LocalDirectory: '/home/francesco/projects/issue/build/app/outputs/flutter-apk'/app.apk
[ +130 ms] ✓  Built build/app/outputs/flutter-apk/app-release.apk (5.8MB).
[  +10 ms] executing: /home/francesco/Android/Sdk/build-tools/30.0.2/aapt dump xmltree /home/francesco/projects/issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[  +22 ms] Exit code 0 from: /home/francesco/Android/Sdk/build-tools/30.0.2/aapt dump xmltree /home/francesco/projects/issue/build/app/outputs/flutter-apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1e
               A: android:compileSdkVersionCodename(0x01010573)="11" (Raw: "11")
               A: package="com.example.issue" (Raw: "com.example.issue")
               A: platformBuildVersionCode=(type 0x10)0x1e
               A: platformBuildVersionName=(type 0x10)0xb
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1e
               E: uses-permission (line=11)
                 A: android:name(0x01010003)="android.permission.READ_EXTERNAL_STORAGE" (Raw: "android.permission.READ_EXTERNAL_STORAGE")
               E: uses-permission (line=12)
                 A: android:name(0x01010003)="android.permission.WRITE_EXTERNAL_STORAGE" (Raw: "android.permission.WRITE_EXTERNAL_STORAGE")
               E: application (line=14)
                 A: android:label(0x01010001)="issue" (Raw: "issue")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=18)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.issue.MainActivity" (Raw: "com.example.issue.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=32)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=42)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=46)
                     E: action (line=47)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=49)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=56)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
                 E: provider (line=60)
                   A: android:name(0x01010003)="io.flutter.plugins.imagepicker.ImagePickerFileProvider" (Raw: "io.flutter.plugins.imagepicker.ImagePickerFileProvider")
                   A: android:exported(0x01010010)=(type 0x12)0x0
                   A: android:authorities(0x01010018)="com.example.issue.flutter.image_provider" (Raw: "com.example.issue.flutter.image_provider")
                   A: android:grantUriPermissions(0x0101001b)=(type 0x12)0xffffffff
                   E: meta-data (line=65)
                     A: android:name(0x01010003)="android.support.FILE_PROVIDER_PATHS" (Raw: "android.support.FILE_PROVIDER_PATHS")
                     A: android:resource(0x01010025)=@0x7f0c0000
[   +6 ms] Stopping app 'app.apk' on Pixel 3a.
[        ] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell am force-stop com.example.issue
[ +128 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell pm list packages com.example.issue
[ +149 ms] package:com.example.issue
[   +3 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell cat /data/local/tmp/sky.com.example.issue.sha1
[  +91 ms] 08474083fdeeb67dc7f29e518da018db8055ee2c
[        ] Installing APK.
[   +1 ms] Installing build/app/outputs/flutter-apk/app.apk...
[        ] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C install -t -r /home/francesco/projects/issue/build/app/outputs/flutter-apk/app.apk
[+1378 ms] Performing Streamed Install
                    Success
[   +4 ms] Installing build/app/outputs/flutter-apk/app.apk... (completed in 1,379ms)
[   +3 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell echo -n a3cdfb03677bf054c67c60f0ee75299b19c8c553 > /data/local/tmp/sky.com.example.issue.sha1
[  +50 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez
enable-dart-profiling true com.example.issue/com.example.issue.MainActivity
[  +96 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.issue/.MainActivity (has extras) }
[   +6 ms] Application running.
[  +10 ms] Flutter run key commands.
[  +13 ms] h Repeat this help message.
[   +1 ms] c Clear the screen
[   +1 ms] q Quit (terminate the application on the device).
[+5408 ms] I/flutter (11605): ********** getting version
[   +2 ms] I/flutter (11605): ########## EXCEPTION: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/package_info)
[        ] I/flutter (11605): ########## STACKTRACE: #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #1      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #2      PackageInfo.fromPlatform (package:package_info/package_info.dart:42)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #3      getVersion (package:issue/main.dart:12)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #4      main.<anonymous closure> (package:issue/main.dart:57)
[        ] I/flutter (11605): <asynchronous suspension>
[+2076 ms] I/flutter (11605): ********** picking image
[+8551 ms] I/flutter (11605): ********** picking image
[   +1 ms] I/flutter (11605): ########## EXCEPTION: PlatformException(already_active, Image picker is already active, null, null)
[        ] I/flutter (11605): ########## STACKTRACE: #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597)
[        ] I/flutter (11605): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #2      MethodChannelImagePicker.pickImage (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:29)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #3      pickImage (package:issue/main.dart:22)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #4      main.<anonymous closure> (package:issue/main.dart:72)
[        ] I/flutter (11605): <asynchronous suspension>
[+2849 ms] I/flutter (11605): ********** picking image
[   +1 ms] I/flutter (11605): ########## EXCEPTION: PlatformException(already_active, Image picker is already active, null, null)
[        ] I/flutter (11605): ########## STACKTRACE: #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597)
[        ] I/flutter (11605): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #2      MethodChannelImagePicker.pickImage (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:29)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #3      pickImage (package:issue/main.dart:22)
[        ] I/flutter (11605): <asynchronous suspension>
[        ] I/flutter (11605): #4      main.<anonymous closure> (package:issue/main.dart:72)
[        ] I/flutter (11605): <asynchronous suspension>
[+10655 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell am force-stop com.example.issue
[ +171 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C shell am force-stop com.example.issue
[  +70 ms] Application finished.
[  +17 ms] "flutter run" took 74,757ms.
[  +80 ms] ensureAnalyticsSent: 72ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 0
pubspec
name: issue
description: A new Flutter project.
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  package_info: ^2.0.0
  image_picker: ^0.7.3

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

doctor
[✓] Flutter (Channel master, 2.1.0-13.0.pre.175, on Linux, locale en_US.UTF-8)
    • Flutter version 2.1.0-13.0.pre.175 at /home/francesco/snap/flutter/common/flutter
    • Framework revision efbde443d2 (21 hours ago), 2021-03-18 13:40:08 -0700
    • Engine revision c4628b709c
    • Dart version 2.13.0 (build 2.13.0-149.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/francesco/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_SDK_ROOT = /home/francesco/Android/Sdk
    • Java binary at: /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~20.04-b08)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /snap/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (3 available)
    • Pixel 3a (mobile) • 965AY0WP5C • android-arm64  • Android 11 (API 30)
    • Linux (desktop)   • linux      • linux-x64      • Linux
    • Chrome (web)      • chrome     • web-javascript • Chromium 89.0.4389.90 snap

! Doctor found issues in 1 category.

note that image_picker hangs forever

@vemarav
Copy link

vemarav commented Mar 20, 2021

@ekasetiawans
Downgrading gradle version to 3.5.0 fixes the issue

  dependencies {
          classpath 'com.android.tools.build:gradle:3.5.0'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
          classpath 'com.google.gms:google-services:4.3.5'
  }

@ekasetiawans
Copy link
Author

@vemarav i think downgrading is not best solution since gradle 4.1.0 is the default version for new flutter application project.

@ekasetiawans
Copy link
Author

ekasetiawans commented Mar 20, 2021

Adding these lines to release buildType in android/app/build.gradle also fix the issue

release {
...
            // add this
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }

can this be caused by proguard / r8? @iapicca

@iapicca
Copy link
Contributor

iapicca commented Mar 20, 2021

Adding these lines to release buildType in android/app/build.gradle also fix the issue

release {
...
            // add this
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }

can this be caused by proguard / r8?

@ekasetiawans
I think you might be right.
I confirm that the solution above solves the problem,
nevertheless I believe the issue should remain open as

  • the error doesn't provide an informative message
  • the documentation should provide clearer steps to avoid the experienced behavior

Downgrading gradle version to 3.5.0 fixes the issue

i think downgrading is not best solution since gradle 4.1.0 is the default version for new flutter application project.

I also agree that downgrading isn't a solution, a workaround at best

@navaronbracke
Copy link
Contributor

@iapicca I agree. Either the project template (flutter create my_app) could include a proguard config that fixes the issue, or we could update the documentation.

@TahaTesser TahaTesser added the in triage Presently being triaged by the triage team label Mar 22, 2021
@TahaTesser
Copy link
Member

TahaTesser commented Mar 22, 2021

Hi @ekasetiawans and everyone.
Looks like this is not related to just image_picker. I can see the same issue without image_picker, the other combination of packages from #78582 (comment) also breaks path_provider and the same solution solves the issue too.

pubspec.yaml
name: stable_flutter
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  # package_info: ^2.0.0
  sembast: ^3.0.0+4
  path_provider: ^2.0.1
  path: ^1.8.0
  uuid: ^3.0.1
  intl: ^0.17.0
  jiffy: ^4.0.0
  rxdart: ^0.26.0
  file_picker: ^3.0.0
  flutter_blue: ^0.8.0
  app_settings: ^4.1.0
  permission_handler: ^6.1.0



dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
logs
Installing build\app\outputs\flutter-apk\app.apk...              1,354ms

Flutter run key commands.
h Repeat this help message.
c Clear the screen
q Quit (terminate the application on the device).
E/flutter (13622): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
E/flutter (13622): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156)
E/flutter (13622): <asynchronous suspension>
E/flutter (13622): #1      getTemporaryDirectory (package:path_provider/path_provider.dart:79)
E/flutter (13622): <asynchronous suspension>
E/flutter (13622):
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
    • Flutter version 2.0.3 at C:\Users\Taha\Code\flutter_stable
    • Framework revision 4d7946a68d (3 days ago), 2021-03-18 17:24:33 -0700
    • Engine revision 3459eb2436
    • Dart version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Taha\Code\SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = C:\Users\Taha\Code\SDK
    • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Users\Taha\AppData\Local\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.9.31112.23
    • Windows 10 SDK version 10.0.18362.0

[✓] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\Taha\Code\android-studio
    • 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-b01)

[✓] VS Code (version 1.54.3)
    • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.20.0

[✓] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19042.867]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 89.0.4389.90
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 89.0.774.45

• No issues found!
[✓] Flutter (Channel master, 2.1.0-13.0.pre.194, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
    • Flutter version 2.1.0-13.0.pre.194 at C:\Users\Taha\Code\flutter_master
    • Framework revision e58ee0fbc7 (4 hours ago), 2021-03-22 13:06:06 +0800
    • Engine revision e6db3a275e
    • Dart version 2.13.0 (build 2.13.0-149.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Taha\Code\SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = C:\Users\Taha\Code\SDK
    • Java binary at: C:\Users\Taha\Code\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Users\Taha\AppData\Local\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.9.31112.23
    • Windows 10 SDK version 10.0.18362.0

[✓] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\Taha\Code\android-studio
    • 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-b01)

[✓] VS Code (version 1.54.3)
    • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.20.0

[✓] Connected device (5 available)
    • Redmi K20 Pro (mobile)  • def0ad20      • android-arm64  • Android 10 (API 29)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19042.867]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 89.0.4389.90
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 89.0.774.45

• No issues found!

Related #70314
#78582 is closed, I'm labeling this issue
Thank you

@TahaTesser TahaTesser added a: release Challenges faced when attempting to productionize an app found in release: 2.0 Found to occur in 2.0 found in release: 2.1 Found to occur in 2.1 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: framework platform-android Android applications specifically and removed in triage Presently being triaged by the triage team labels Mar 22, 2021
@TahaTesser TahaTesser changed the title Image Picker breaks anothers plugins on release mode Some plugins breaks on release mode on Android Mar 22, 2021
@TahaTesser TahaTesser added plugin c: crash Stack traces logged to the console labels Mar 22, 2021
@SebAubin
Copy link

SebAubin commented Mar 22, 2021

After adding the @ekasetiawans code in my build.gradle, i've got this error:

03-22 10:45:44.249 14827 14827 E AndroidRuntime: Process: net.devolutions.hub_app, PID: 14827
03-22 10:45:44.249 14827 14827 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Can't obtain peer field ID for class com.sun.jna.Pointer
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at com.sun.jna.Native.initIDs(Native Method)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at com.sun.jna.Native.<clinit>(Unknown Source:276)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at com.sun.jna.Native.z(Unknown Source:0)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at j.a.a.d.b.x(Unknown Source:4)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at net.devolutions.hub_app.MainActivity$b.b(Unknown Source:857)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at g.a.d.a.j$a.a(Unknown Source:17)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at g.a.c.b.e.b.d(Unknown Source:57)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at android.os.MessageQueue.nativePollOnce(Native Method)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at android.os.MessageQueue.next(MessageQueue.java:336)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:197)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8167)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
03-22 10:45:44.249 14827 14827 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
03-22 10:45:44.252  1352 20026 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2

Did a little searching and found that it would be related to the proguard setting proviously added but I can't find how to fix this issue. I've created a proguard-rules.txt file but it's not working..

@navaronbracke
Copy link
Contributor

@SebAubin I used a proguard-rules.pro file that contains these rules:

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

@SebAubin
Copy link

You've created a file named proguard-rules.pro in your app folder and added these lines inside?

@SebAubin
Copy link

That's what I did and I can confirm that it's working! Thank you @navaronbracke

@TahaTesser TahaTesser added the customer: crowd Affects or could affect many people, though not necessarily a specific customer. label Mar 23, 2021
@nt4f04uNd
Copy link
Member

i had a similar issue #75681
all of a sudden release builds started being obfuscated in flutter above 1.24

@iapicca
Copy link
Contributor

iapicca commented Mar 23, 2021

all of a sudden release builds started being obfuscated in flutter above 1.24

@TahaTesser maybe should be considered a regression

@jmagman jmagman added the t: gradle "flutter build" and "flutter run" on Android label Mar 23, 2021
@xster
Copy link
Member

xster commented Mar 24, 2021

I haven't see anyone actually state that the issue is specifically with androidx.lifecycle.DefaultLifecycleObserver.

From testing by inserting a -dontobfuscate into https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter_proguard_rules.pro just so we know exactly what we're dealing with shows that the actual issue is via the chain ImagePickerPlugin.LifecycleObserver which implements DefaultLifecycleObserver which according to https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:lifecycle/lifecycle-common-java8/src/main/java/androidx/lifecycle/DefaultLifecycleObserver.java implements FullLifecycleObserver seems to be the issue.

com.example.t183_plugin_proguard E/GeneratedPluginsRegister: Received exception java.lang.IllegalAccessError: Interface androidx.lifecycle.FullLifecycleObserver implemented by class io.flutter.plugins.imagepicker.ImagePickerPlugin$LifeCycleObserver is inaccessible (declaration of 'io.flutter.plugins.imagepicker.ImagePickerPlugin$LifeCycleObserver' appears in

But inexplicably, FullLifecycleObserver is in the dex too.

Screen Shot 2021-03-24 at 3 12 16 AM

And the issue is not the obfuscation since I tested with it turned off.

@xster
Copy link
Member

xster commented Mar 24, 2021

But androidx.lifecycle.DefaultLifecycleObserver IS otherwise missing from the dex and adding -keep class androidx.lifecycle.DefaultLifecycleObserver does work.

@zoeou
Copy link

zoeou commented Mar 25, 2021

How to fix the conflict between webview_flutter and image_picker

doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 2.1.0-13.0.pre.207, on Microsoft Windows [Version 10.0.18363.1440], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 3.2)
[√] IntelliJ IDEA Ultimate Edition (version 2020.2)
[√] VS Code (version 1.54.3)
[√] Connected device (3 available)

pubspec.yaml

  cupertino_icons: ^1.0.2
  webview_flutter: ^2.0.2
  shared_preferences: ^2.0.1
  image_picker: ^0.6.7+22

run:

flutter run --release

log:

E/flutter (19222): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview
E/flutter (19222):      at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(Unknown Source:229)
E/flutter (19222):      at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(Unknown Source:152)
E/flutter (19222):      at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(Unknown Source:144)
E/flutter (19222):      at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
E/flutter (19222):      at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:57)
E/flutter (19222):      at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter (19222):      at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (19222):      at android.os.MessageQueue.next(MessageQueue.java:363)
E/flutter (19222):      at android.os.Looper.loop(Looper.java:176)
E/flutter (19222):      at android.app.ActivityThread.main(ActivityThread.java:8349)
E/flutter (19222):      at java.lang.reflect.Method.invoke(Native Method)
E/flutter (19222):      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/flutter (19222):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
E/flutter (19222): , null, null)
E/flutter (19222): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597)
E/flutter (19222): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
E/flutter (19222): <asynchronous suspension>
E/flutter (19222): #2      TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1044)
E/flutter (19222): <asynchronous suspension>
E/flutter (19222): #3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:750)
E/flutter (19222): <asynchronous suspension>
E/flutter (19222): #4      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:194)
E/flutter (19222): <asynchronous suspension>

@xster
Copy link
Member

xster commented Mar 25, 2021

It's unrelated. Please file a separate issue for that.

@stuartmorgan
Copy link
Contributor

It's unrelated.

I'm not sure it is; registering platform view factories happens in the plugin's registration method, so just as some plugins won't get their method channels registered when this happens, webview_flutter wouldn't have its factory registered, which would mean the type wouldn't be recognized.

@xster
Copy link
Member

xster commented Mar 25, 2021

Ah that's a good deciphering. Thanks

@Saavedra22
Copy link

Saavedra22 commented Mar 29, 2021

Any answer on this issue, apply several fixes that present but I still have the same problem.
My device is a xiaomi redmi 7 with android 10 and the latest flutter version.

#79293

@blasten blasten self-assigned this Mar 29, 2021
@xster
Copy link
Member

xster commented Mar 30, 2021

This should now be solved by the newly published https://pub.dev/packages/flutter_plugin_android_lifecycle version 2.0.1 (which some plugins such depend on transitively). Doing a flutter pub upgrade and looking for a > flutter_plugin_android_lifecycle 2.0.1 line should resolve the issue.

@github-actions
Copy link

github-actions bot commented Aug 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
@flutter-triage-bot flutter-triage-bot bot added P0 Critical issues such as a build break or regression and removed P2 labels Jun 28, 2023
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: release Challenges faced when attempting to productionize an app c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. found in release: 2.0 Found to occur in 2.0 found in release: 2.1 Found to occur in 2.1 has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression package flutter/packages repository. See also p: labels. platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet