java.lang.RuntimeException:找不到 API 密钥



我是颤振的新手,并使用谷歌地图服务尝试颤振,我的Android清单如下所示,我的api密钥也受到限制:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.succo.succo">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="my real key."/>
</application>
</manifest>

当我尝试运行颤振应用程序时,我一直收到错误消息说java.lang.RuntimeException: API key not found,然后整个错误日志如下所示:

Launching libmain.dart on Android SDK built for x86 in debug mode...
Built buildappoutputsapkdebugapp-debug.apk.
I/flutter ( 5552): Overflow on channel: flutter/lifecycle.  Messages on this channel are being discarded in FIFO fashion.  The engine may not be running or you need to adjust the buffer size if of the channel.
I/zzbz    ( 5552): Making Creator dynamically
D/        ( 5552): HostConnection::get() New Host Connection established 0xceaeab80, tid 5566
D/EGL_emulation( 5552): eglMakeCurrent: 0xe2e0f5e0: ver 2 0 (tinfo 0xe2e10610)
I/flutter ( 5552): current location is:
I/flutter ( 5552): 37.4219983
I/flutter ( 5552): -122.084
W/com.succo.succ( 5552): Unsupported class loader
W/com.succo.succ( 5552): Skipping duplicate class check due to unsupported classloader
I/DynamiteModule( 5552): Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
I/DynamiteModule( 5552): Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
V/DynamiteModule( 5552): Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/com.succo.succ( 5552): Unsupported class loader
W/com.succo.succ( 5552): Skipping duplicate class check due to unsupported classloader
I/Google Maps Android API( 5552): Google Play services client version: 12451000
I/Google Maps Android API( 5552): Google Play services package version: 19420040
E/MethodChannel#flutter/platform_views( 5552): Failed to handle method call
E/MethodChannel#flutter/platform_views( 5552): java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
E/MethodChannel#flutter/platform_views( 5552):  at com.google.maps.api.android.lib6.drd.p.b(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):22)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.maps.api.android.lib6.auth.d.a(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):80)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.maps.api.android.lib6.impl.d.a(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):41)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.internal.CreatorImpl.a(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):54)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.internal.CreatorImpl.newMapViewDelegate(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):32)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.internal.h.a(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):62)
E/MethodChannel#flutter/platform_views( 5552):  at cv.onTransact(:com.google.android.gms.dynamite_mapsdynamite@19420084@19.4.20 (100700-271418971):4)
E/MethodChannel#flutter/platform_views( 5552):  at android.os.Binder.transact(Binder.java:667)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.internal.maps.zza.zza(Unknown Source:10)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.internal.zzf.zza(Unknown Source:19)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.MapView$zzb.createDelegate(Unknown Source:13)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(Unknown Source:18)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate(Unknown Source:22)
E/MethodChannel#flutter/platform_views( 5552):  at com.google.android.gms.maps.MapView.onCreate(Unknown Source:26)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugins.googlemaps.GoogleMapController.init(GoogleMapController.java:136)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugins.googlemaps.GoogleMapBuilder.build(GoogleMapBuilder.java:32)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugins.googlemaps.GoogleMapFactory.create(GoogleMapFactory.java:51)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:174)
E/MethodChannel#flutter/platform_views( 5552):  at android.app.Dialog.dispatchOnCreate(Dialog.java:407)
E/MethodChannel#flutter/platform_views( 5552):  at android.app.Dialog.show(Dialog.java:302)
E/MethodChannel#flutter/platform_views( 5552):  at android.app.Presentation.show(Presentation.java:249)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:93)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:53)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugin.platform.PlatformViewsController$1.createPlatformView(PlatformViewsController.java:105)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:96)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#flutter/platform_views( 5552):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:645)
E/MethodChannel#flutter/platform_views( 5552):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views( 5552):  at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#flutter/platform_views( 5552):  at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#flutter/platform_views( 5552):  at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#flutter/platform_views( 5552):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views( 5552):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#flutter/platform_views( 5552):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

这有点棘手,有两个AndroidManifest.xml文件,一个在profile/下,另一个在main/下,你需要将API密钥添加到main/下的清单文件中。

我在两个manifest中添加了键:

  • 一进下主/
  • 其他在配置文件/

现在它正在工作。

相关内容

  • 没有找到相关文章

最新更新