1

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?

for-questions
  • 61
  • 1
  • 6

3 Answers3

4

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

for-questions
  • 61
  • 1
  • 6
0

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

<uses-permission android:name="android.permission.INTERNET" />
Saeed All Gharaee
  • 1,546
  • 1
  • 14
  • 27
-1
  • 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.

RuslanBek
  • 1,592
  • 1
  • 14
  • 30
  • 1
    I'm talking about release app under internal testing. Where I suppose to run flutter clean? – for-questions Apr 23 '21 at 14:13
  • @for-questions oh sorry i didn't read your question fully. Though here `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` it says u should upgrade `cloud_firestore` package. you should upgrade your `flutter sdk` and `flutter packages` inside your app. Probably you should also read `migration guides` of packages if needed.It is due to breaking changes if there were some. – RuslanBek Apr 23 '21 at 18:25
  • No need to sorry. I appreciate you help – for-questions Apr 23 '21 at 19:05
  • @for-questions read my last comment carefully and try to apply those methods – RuslanBek Apr 23 '21 at 19:07
  • 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? – for-questions Apr 24 '21 at 12:47
  • @for-questions try answers from this link https://stackoverflow.com/questions/49874194/flutter-release-apk-is-not-working-properly. Try all answers. Do not focus on accepted one – RuslanBek Apr 24 '21 at 13:05
  • Ruslanbek0809 Thank you very much. – for-questions Apr 24 '21 at 15:28
  • 1
    You can't imagine how grateful I am – for-questions Apr 24 '21 at 15:29