Я пытаюсь отобразить виджет Google Maps на моем экране. Виджет работает безупречно для iOS (см. Рисунок 1), но отображает только google lo go и серый экран (см. Рисунок 2) на устройстве Android, и у меня возникают проблемы при определении проблемы.
Я предполагаю, что это проблема с ключом API, однако в настоящее время я просто использую открытый ключ c, который я создал без ограничений, просто чтобы попытаться заставить что-то работать. Я настроил манифест android правильно
Рисунок 1: Работает iOS Выход
Рисунок 2: Не работает Android Выход
Вывод отладки:
✓ Built build/app/outputs/apk/debug/app-debug.apk.
D/FlutterActivity(31362): Using the launch theme as normal theme.
D/FlutterActivityAndFragmentDelegate(31362): Setting up FlutterEngine.
D/FlutterActivityAndFragmentDelegate(31362): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
D/FlutterActivityAndFragmentDelegate(31362): Attaching FlutterEngine to the Activity that owns this Fragment.
D/FlutterView(31362): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@f81b727
D/FlutterActivityAndFragmentDelegate(31362): Executing Dart entrypoint: main, and sending initial route: /
D/EGL_emulation(31362): eglMakeCurrent: 0xcfd1a5a0: ver 3 0 (tinfo 0xb8ce7e40)
W/Gralloc4(31362): allocator 3.x is not supported
W/Gralloc3(31362): allocator 3.x is not supported
I/zzbz (31362): Making Creator dynamically
W/s_app_prototyp(31362): Unsupported class loader
I/DynamiteModule(31362): Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:222
I/DynamiteModule(31362): Selected remote version of com.google.android.gms.maps_dynamite, version >= 222
V/DynamiteModule(31362): Dynamite loader version >= 2, using loadModule2NoCrashUtils
I/Google Maps Android API(31362): Google Play services client version: 12451000
I/Google Maps Android API(31362): Google Play services package version: 200616040
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->peekLong(JZ)J (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->pokeLong(JJZ)V (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->pokeInt(JIZ)V (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->peekInt(JZ)I (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->pokeByte(JB)V (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->peekByte(J)B (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->pokeByteArray(J[BII)V (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Llibcore/io/Memory;->peekByteArray(J[BII)V (greylist, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->arrayBaseOffset(Ljava/lang/Class;)I (greylist,core-platform-api, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->arrayIndexScale(Ljava/lang/Class;)I (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/s_app_prototyp(31362): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, reflection, allowed)
W/s_app_prototyp(31362): Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, reflection, allowed)
Android Манифест:
package="com.example.ms_app_prototype">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="ms_app_prototype"
android:icon="@mipmap/ic_launcher">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="inserted correct value"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Виджет карты дротиков:
import 'package:google_maps_flutter/google_maps_flutter.dart';
class Map extends StatelessWidget {
GoogleMapController mapController;
final LatLng _center = const LatLng(33.509186, -112.020682);
void _onMapCreated(GoogleMapController controller) {
mapController = controller;
}
@override
Widget build(BuildContext context) {
return Container(
child: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 15.0,
),
),
);
}
}