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
[google_maps_flutter] App crashes when using maps in release mode. #69820
Comments
Hmm, I assume that the interface whose name is obfuscated away is DefaultLifecycleObserver. However, that change did not change use of the interface (though it did remove one implementation). Looks like this is a common issue throughout flutter. See #58479. I think this should be easy to fix in the plugin. |
Or maybe it's not specifically an issue with the library, and you just need to follow the advice in that other fix. Let me know if that makes sense and works. |
Hi @slightfoot code sampleimport 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Google Maps Demo',
home: MapSample(),
);
}
}
class MapSample extends StatefulWidget {
@override
State<MapSample> createState() => MapSampleState();
}
class MapSampleState extends State<MapSample> {
Completer<GoogleMapController> _controller = Completer();
static final CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
static final CameraPosition _kLake = CameraPosition(
bearing: 192.8334901395799,
target: LatLng(37.43296265331129, -122.08832357078792),
tilt: 59.440717697143555,
zoom: 19.151926040649414);
@override
Widget build(BuildContext context) {
return new Scaffold(
body: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
floatingActionButton: FloatingActionButton.extended(
onPressed: _goToTheLake,
label: Text('To the lake!'),
icon: Icon(Icons.directions_boat),
),
);
}
Future<void> _goToTheLake() async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
}
build.gradledef localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.nevercode.triage"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
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'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
logstahatesser@Tahas-MacBook-Pro google_maps_flutter_example % flutterd run --release -d rmx
Running "flutter pub get" in google_maps_flutter_example... 461ms
Launching lib/main.dart on RMX2001 in release mode...
Note: /Users/tahatesser/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.7/android/src/main/java/io/flutter/plugins/flutter_plugin_android_lifecycle/FlutterAndroidLifecyclePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/tahatesser/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-1.0.6/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 32.0s
✓ Built build/app/outputs/flutter-apk/app-release.apk (6.2MB).
Installing build/app/outputs/flutter-apk/app.apk... 3.9s
Flutter run key commands.
h Repeat this help message.
c Clear the screen
q Quit (terminate the application on the device).
flutter doctor -v[✓] Flutter (Channel dev, 1.24.0-7.0.pre, on Mac OS X 10.15.7 19H2 darwin-x64,
locale en-GB)
• Flutter version 1.24.0-7.0.pre at /Users/tahatesser/Code/flutter_dev
• Framework revision a0860f6e87 (6 days ago), 2020-10-29 20:07:34 -0700
• Engine revision 073263e39d
• Dart version 2.11.0 (build 2.11.0-260.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/tahatesser/Code/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/tahatesser/Code/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-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
• Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0
[✓] 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-6222593)
[✓] VS Code (version 1.50.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[✓] Connected device (5 available)
• RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 •
Android 10 (API 29)
• Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS
14.1
• macOS (desktop) • macos • darwin-x64 • Mac OS
X 10.15.7 19H2 darwin-x64
• Web Server (web) • web-server • web-javascript •
Flutter Tools
• Chrome (web) • chrome • web-javascript • Google
Chrome 86.0.4240.183
• No issues found!
Can you please provide step by steps to reproduce the issue crash |
I also tried to reproduce it and failed. For Proguard issues I'd typically expect the error to be about a missing class, not about an inaccessible class. @slightfoot are you just running the example app as-is? is there something special in your environment? does this reproduce everytime you try? cc @blasten edit: @slightfoot did you by chance update the Android Gradle Plugin version for the example app? |
this issue is appeared to me in release mode while is debug mode it work so i am waiting to solve it ... please help me |
Please thoroughly read #58479 and see if the suggestions there provide a solution. On the other hand, I wonder if the problem is that the Google Maps module doesn't have an explicit gradle dependency on |
@slightfoot The proguard |
Without additional information, we are unfortunately not sure how to resolve this issue. Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of |
issue is not solved! E/AndroidRuntime(25599): java.lang.IllegalAccessError: Interface androidx.lifecycle.b implemented by class io.flutter.plugins.googlemaps.GoogleMapController is inaccessible (declaration of 'io.flutter.plugins.googlemaps.GoogleMapController' appears in ...
E/AndroidRuntime(25599): at io.flutter.plugins.googlemaps.g.a(Unknown Source:2)
E/AndroidRuntime(25599): at io.flutter.plugin.platform.SingleViewPresentation.onCreate(Unknown Source:116)
E/AndroidRuntime(25599): at android.app.Dialog.dispatchOnCreate(Dialog.java:702)
E/AndroidRuntime(25599): at android.app.Dialog.show(Dialog.java:424)
E/AndroidRuntime(25599): at android.app.Presentation.show(Presentation.java:283)
E/AndroidRuntime(25599): at io.flutter.plugin.platform.l.<init>(Unknown Source:55)
E/AndroidRuntime(25599): at io.flutter.plugin.platform.l.a(Unknown Source:65)
E/AndroidRuntime(25599): at io.flutter.plugin.platform.k$a.g(Unknown Source:110)
E/AndroidRuntime(25599): at io.flutter.embedding.engine.i.i$a.b(Unknown Source:152)
E/AndroidRuntime(25599): at io.flutter.embedding.engine.i.i$a.G(Unknown Source:144)
E/AndroidRuntime(25599): at f.a.c.a.j$a.a(Unknown Source:17)
E/AndroidRuntime(25599): at io.flutter.embedding.engine.e.b.d(Unknown Source:57)
E/AndroidRuntime(25599): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/AndroidRuntime(25599): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(25599): at android.os.MessageQueue.next(MessageQueue.java:336)
E/AndroidRuntime(25599): at android.os.Looper.loop(Looper.java:197)
E/AndroidRuntime(25599): at android.app.ActivityThread.main(ActivityThread.java:8154)
E/AndroidRuntime(25599): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(25599): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
E/AndroidRuntime(25599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) [✓] Flutter (Channel dev, 1.26.0-1.0.pre, on macOS 11.1 20C69 darwin-x64, locale ru-RU)
• Flutter version 1.26.0-1.0.pre at /Users/pavelmiheev/Flutter
• Framework revision 63062a6443 (5 days ago), 2020-12-13 23:19:13 +0800
• Engine revision 4797b06652
• Dart version 2.12.0 (build 2.12.0-141.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/pavelmiheev/Library/Android/sdk
• Platform android-30, build-tools 29.0.2
• 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 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.3
[✓] 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)
[✓] Connected device (1 available)
• SM G985F (mobile) • R58N210SHRV • android-arm64 • Android 10 (API 29)
• No issues found! |
@pamir72 |
flutter run --release Crash and exception when call widget GoogleMap. dependencies { |
Hi @pamir72 |
Thank you. But I can't use 3.5.0 because firebase_messaging 8.0.0-dev.11 has build problems with 3.5.x and firebase_messaging 7.0.3 crashes app when a message arrives . A desperate situation ) |
have you guys solved the issue? same problem here |
i have same problem here. i using google map flutter 1.1.0 and run app on physical device alway crash app. any ide for fix it ? thank ! :( |
@shibatatsuya0611 Hey mate, I already solved these issues. It's very frustrating since no one tells us what the solution is. dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
} and also adding new file then add this line |
Updated Flutter to ver. 1.26.0-12.0.pre. Issue is not resolved ! |
@pamir72 it's not the flutter SDK that makes an error. I am sure it's gradle version |
Still unsolved! Logs
flutter doctor -v
|
hey guys ! |
I do not understand, I have tried your method and all the ways above but it has not been solved. |
u just select open file gradle.properties on foder android then add this line code: android.enableDexingArtifactTransform=false |
@shibatatsuya0611
|
thanks.....niktob560...it is working with gradle 4.1.2 |
can you @niktob560 give us example how to put this on gradle file ? |
Ok android {
...
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
...
}
}
...
}
Modifyed UPD: it's kinda dirty workaround, remove it after this fix |
Thanks Bro @niktob560, its working well ... |
Great, I had the same issue and now it worked with the solution of @niktob560. |
where is |
@temirfe use your file explorer and search for "proguard" in the root directory where you have your app. There will be several proguard files. proguard rules pro will also be there |
Thanks a lot @niktob560, it works like a charm. |
You can just modify this file |
Hi @slightfoot, you issue can't be reproduiced. |
@didierboka |
Great i trying this current version on my real project and make callback. |
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 |
Updating google_maps_flutter to 2.0.2(google_maps_flutter: ^2.0.2) worked for me. |
This works for me too. |
Excellent |
I confirm that this solved my issue by using the 1st StepAs you can see here, google maps use Gradle Version was 3.x, that's why it crashes. Add the line below to android/build.gradle file. // android/build.gradle
buildscript {
....
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' // downgrade to 3.5.0
....
}
} 2nd StepThe second step is more important, because google() repository is a shortcut to Google's Maven Repository which is introduced in Gradle 4.x. When 3.x version is used, it will crash again. Add the line below to android/build.gradle file. // android/build.gradle
allprojects {
repositories {
maven { url 'https://maven.google.com' } // this should be added
google() // Google's Maven repository
jcenter()
}
} FMI, refer to difference between google() and maven { url 'https://maven.google.com' }. |
does upgrading the packages to I can see some suggestions to downgrade |
@niktob560 not work for me W/DynamiteModule( 1000): Local module descriptor class for com.google.android.gms.googlecertificates not found. |
1 similar comment
@niktob560 not work for me W/DynamiteModule( 1000): Local module descriptor class for com.google.android.gms.googlecertificates not found. |
@laxkarparas1 looks like it's an another issue, provide more information about an issue (and maybe open another issue) |
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 |
Steps to Reproduce
Build maps example in release mode. Proguard strips out native code used for new Android Lifecycle Management introduced by flutter/plugins#3213
Logs
The text was updated successfully, but these errors were encountered: