for-questions
for-questions

Reputation: 101

google_maps_flutter doesn't work in release

I created simple flutter app (Android only) 1 year ago and forgot about it. Now all of a sudden it has to be in production. This app contains firebase auth , firestore database and google map with Places API.

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations: # Add this line
    sdk: flutter
  firebase_auth: ^0.14.0+5
  provider: ^3.1.0
  animated_text_kit: ^3.1.2
  liquid_pull_to_refresh: ^2.0.0
  url_launcher: ^5.7.10
  expandable: ^4.1.4
  image_picker: ^0.6.7+22
  http: ^0.12.1
  geoflutterfire: ^2.0.3+3
  flutter_spinkit: "^4.1.2"
  share: ^0.6.5
  intl: ^0.16.1
  firebase_messaging: ^6.0.1
  flutter_slidable: ^0.5.7
  country_code_picker: ^1.5.0
  flutter_rating_bar: ^3.1.0
  cloud_firestore: ^0.12.9+4
  google_maps_flutter: ^0.5.30
  cupertino_icons: ^1.0.0

All was good in debug mode. But now when I start to make releases and put them into Play Console I have a big problem. Google Map (_which is the key element of the app) is not working (not visible). Places API works BTW. I've read all questions here and I played with API key restrictions (fingerprints) in Google developer console and Firebase console and lot more. Without avail. When I build new release on my local machine with "flutter build appbundle" I see errors in logs.

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.13.7\android\src\main\java\io\flutter\plugins\
firebase\cloudfirestore\CloudFirestorePlugin.java uses or overrides a deprecated API.   

And when I run my app in release mode on device after I got it from Play Store (internal testing) I see this error in logs concerning Google map

E/flutter ( 7124): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: 
PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/google_maps
E/flutter ( 7124):      at io.flutter.plugin.platform.k$a.d(Unknown Source:229)
E/flutter ( 7124):      at io.flutter.embedding.engine.i.i$a.b(Unknown Source:152)
E/flutter ( 7124):      at io.flutter.embedding.engine.i.i$a.J(Unknown Source:144)
E/flutter ( 7124):      at c.a.d.a.i$a.a(Unknown Source:17)
E/flutter ( 7124):      at io.flutter.embedding.engine.e.b.d(Unknown Source:57)
E/flutter ( 7124):      at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
E/flutter ( 7124):      at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 7124):      at android.os.MessageQueue.next(MessageQueue.java:379)
E/flutter ( 7124):      at android.os.Looper.loop(Looper.java:144)
E/flutter ( 7124):      at android.app.ActivityThread.main(ActivityThread.java:7529)
E/flutter ( 7124):      at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 7124):      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
E/flutter ( 7124):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
E/flutter ( 7124): , null, null)
E/flutter ( 7124): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582)
E/flutter ( 7124): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159)
E/flutter ( 7124): <asynchronous suspension>
E/flutter ( 7124): #2      TextureAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1039)
E/flutter ( 7124): <asynchronous suspension>
E/flutter ( 7124): #3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:749)
E/flutter ( 7124): <asynchronous suspension>
E/flutter ( 7124): #4      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:174)
E/flutter ( 7124): <asynchronous suspensio

I'm a JS developer so Dart is easy to grasp but Java is hard for me. Please shed some light on the problem. What is going on here and what to do in this situation? I'd be much obliged. PS.... All works great in debug mode locally. Also I created the copy of my app and deleted ALL code and dependencies except related to google-map package and built new release. No map appeared. So problem is with this google-map only and no dependency conflict I think.!!! One more observation - Image picker and URL launcher do not work either in release from Google Play Console. But If I run flutter run --release locally all is good again. I'm wondering - maybe I have to add some access policy or something in Play console?

Upvotes: 2

Views: 3913

Answers (3)

Saeed All Gharaee
Saeed All Gharaee

Reputation: 1683

Make sure you had added this line of code in Manifest:

<uses-permission android:name="android.permission.INTERNET" />

Upvotes: 0

RuslanBek
RuslanBek

Reputation: 2009

  • Uninstall the app
  • Run flutter command flutter clean.
  • Run your app again.

Note: I didn't read question fully. That's why this answer is not for release but for debug apk.

Upvotes: -1

for-questions
for-questions

Reputation: 101

After a very long search and mainly thanks to the help of Ruslanbek0809 I solved this problem at last.
In android/app/build.gradle I added:
shrinkResources false and minifyEnabled false to the buildTypes

    buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources false
            minifyEnabled false
        }
    }

And a miracle happened

Upvotes: 7

Related Questions