google_maps_flutter在发布中不起作用



我一年前创建了一个简单的flutter应用程序(仅限Android(,但忘记了它。现在突然之间,它不得不投入生产。此应用程序包含firebase验证、firestore数据库和带有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

在调试模式下一切都很好。但现在,当我开始发布并将其放入Play控制台时,我遇到了一个大问题。谷歌地图(_它是应用程序的关键元素(不起作用(不可见(。API工作场所BTW。我已经阅读了这里的所有问题,并在Google开发者控制台和Firebase控制台中玩了API密钥限制(指纹(等等。无效。当我在本地机器上构建新版本时;flutter构建appbundle";我在日志中看到错误。

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:flutter.pub-cachehostedpub.dartlang.orgcloud_firestore-0.13.7androidsrcmainjavaioflutterplugins
firebasecloudfirestoreCloudFirestorePlugin.java uses or overrides a deprecated API.   

当我从Play Store(内部测试(获得应用程序后,在设备上以发布模式运行应用程序时,我在有关谷歌地图的日志中看到了这个错误

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

我是一名JS开发人员,所以Dart很容易掌握,但Java对我来说很难。请阐明这个问题。这里发生了什么,在这种情况下该怎么办?我将不胜感激。PS…在本地调试模式下一切都很好。此外,我创建了我的应用程序的副本,删除了除了与谷歌地图包相关的所有代码和依赖项,并构建了新版本。没有出现地图。所以问题是这个谷歌地图只有,并没有依赖冲突,我认为!!!还有一个观察-图像选择器和URL启动器在Google Play控制台发布时也不起作用。但如果我运行flutter run——本地释放,一切都会好起来。我想知道-也许我必须在Play控制台中添加一些访问策略或其他什么

经过很长时间的搜索,主要归功于Ruslanbek0809的帮助,我终于解决了这个问题
在android/app/build.gradle中,我向buildTypes 添加了:
shrinkResources false和minimyEnabled false

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

奇迹发生了

确保在Manifest:中添加了这行代码

<uses-permission android:name="android.permission.INTERNET" />
  • 卸载应用程序
  • 运行颤振命令flutter clean
  • 再次运行您的应用程序

注意:我并没有完全阅读这个问题。这就是为什么这个答案不是为了发布,而是为了调试apk。

相关内容

  • 没有找到相关文章

最新更新