#flutter #mapbox-gl
#flutter #mapbox-gl
Вопрос:
Я хочу интегрировать mapbox с помощью flutter То, что я делаю, это просто устанавливаю свой sdk в pubsec.yaml и помещаю токен доступа в файл манифеста Android и Info.plist
Вот мой pubsec.yaml, куда я добавляю mapbox_gl
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
mapbox_gl: ^0.0.3
Я еще не добавил никакого кода в файл dart и просто пытаюсь запустить приложение, но оно выдает ошибку
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:16: error: cannot find symbol
import androidx.annotation.NonNull;
^
symbol: class NonNull
location: package androidx.annotation
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:130: error: cannot find symbol
private static String getAccessToken(@NonNull Context context) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:298: error: cannot find symbol
private void enableLocationComponent(@NonNull Style style) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:315: error: cannot find symbol
private void enableSymbolManager(@NonNull Style style) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:326: error: cannot find symbol
private void enableLineManager(@NonNull Style style) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:333: error: cannot find symbol
private void enableCircleManager(@NonNull Style style) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:556: error: cannot find symbol
public boolean onMapClick(@NonNull LatLng point) {
^
symbol: class NonNull
location: class MapboxMapController
/flutter/.pub-cache/hosted/pub.dartlang.org/mapbox_gl-0.0.3/android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java:286: error: cannot find symbol
public void onStyleLoaded(@NonNull Style style) {
^
symbol: class NonNull
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
8 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mapbox_gl:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
BUILD FAILED in 4s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
Любая помощь приветствуется.
Комментарии:
1. не могли бы вы показать мне pubsec.yaml.
2. как вы добавляете mapbox gl
Ответ №1:
Это проблема совместимости с AndroidX.
Добавьте это в свой android/gradle.properties
и попробуйте построить снова:
android.enableJetifier=true
android.useAndroidX=true