1

我已经按照包的开发页面上的步骤进行操作:https ://pub.dev/packages/google_maps_flutter 但是当我在输入我的 api 密钥后运行它时,我得到的只是一个空白屏幕,如下所示:
截图

AndroidManifest.xml 看起来像这样:

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="foodiesapp"
        android:icon="@mipmap/ic_launcher">   
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="AIzaSyB........"/>
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

主页是包开发页面示例中的确切代码:https ://pub.dev/packages/google_maps_flutter

有谁知道问题可能是什么?

4

1 回答 1

1

将 API_KEY 元数据移动到主要活动之上。

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="foodiesapp"
        android:icon="@mipmap/ic_launcher">
        <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="AIzaSyB........"/> <!--here-->
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
于 2020-07-31T20:36:35.397 回答