Mapbox using flutter - flutter

I want to integrate mapbox using flutter
The thing I am doing is just installing my sdk in pubsec.yaml and placing the access token in Android Manifest file and Info.plist
Here is my pubsec.yaml where I am adding 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
I have not yet added any code in dart file and just trying to run the application but it gives me the error
/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
Any help is appreciated.

That's an AndroidX compatibility issue.
Add this to your android/gradle.properties and try to build again:
android.enableJetifier=true
android.useAndroidX=true
(Official docs about AndroidX migration on Flutter)

Related

Flutter error: Execution failed for task ':location_permissions:compileDebugJavaWithJavac'

Tried to run my flutter app on a physical device, and the following error keeps showing:
Launching lib/main.dart on Pixel 3a in debug mode...
Running Gradle task 'assembleDebug'...
Note: /Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/google_api_availability-2.0.4/android/src/main/java/com/baseflow/googleapiavailability/GoogleApiAvailabilityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.3.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.2.2/android/src/main/java/io/flutter/plugins/firebase/firestore/FlutterFirebaseFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-2.2.2/android/src/main/java/io/flutter/plugins/firebase/firestore/streamhandler/TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:284: error: cannot find symbol
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION));
^
symbol: variable Q
location: class VERSION_CODES
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:284: error: cannot find symbol
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION));
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:308: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
^
symbol: variable Q
location: class VERSION_CODES
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:309: error: cannot find symbol
names.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:330: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && hasPermissionInManifest(Manifest.permission.ACCESS_BACKGROUND_LOCATION, context)) {
^
symbol: variable Q
location: class VERSION_CODES
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:330: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && hasPermissionInManifest(Manifest.permission.ACCESS_BACKGROUND_LOCATION, context)) {
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:331: error: cannot find symbol
permissionNames.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
/Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java:372: error: cannot find symbol
return locationManager.isLocationEnabled();
^
symbol: method isLocationEnabled()
location: variable locationManager of type LocationManager
Note: /Users/jasonlloyd/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-3.0.0+1/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':location_permissions: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.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
I've tried following the advice here: Execution Failed for task :app:compileDebugJavaWithJavac in Android Studio but doesn't work still. Any ideas?
Did you allow Background location in Manifest?
<manifest ... >
<!-- Required only when requesting background location access on
Android 10 (API level 29) and higher. -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
</manifest>
Solved! I simply needed to update one of my dependencies in pubspec.yaml to the latest version, specifically changing location pacakage to location: ^4.3.0. Hope this helps someone in the future.

Failed to precompile build_runner:build_runner:

I created a new project, added dependencies
when I launch it
flutter pub run build_runner build
I get:
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:1600:40: Error: Getter not found: 'topLevelVariable'.
return kinds.contains(TargetKind.topLevelVariable);
^^^^^^^^^^^^^^^^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Getter not found: 'topLevelVariable'.
case TargetKind.topLevelVariable:
^^^^^^^^^^^^^^^^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2024:23: Error: Type 'dynamic' of the case expression is not a subtype of type 'TargetKind' of this switch
expression.
- 'TargetKind' is from 'package:meta/meta_meta.dart' ('/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0/lib/meta_meta.dart').
case TargetKind.topLevelVariable:
^
/C:/Users/Michael/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.6.0/lib/src/error/best_practices_verifier.dart:2001:13: Context: The switch expression is here.
switch (this) {
^
pub finished with exit code 1
I've read everything on stackoverflow, but I haven't found a solution.
Any idea?
Specify the analyzer version
analyzer: 1.5.0
Warning: do not up to the latest version, because it depends on meta package as is flutter_test - where you can't specify the version

Flutter Camera Plugin Version 0.8.1 not compatible with AndroidX

When executing Flutter run I'm getting the following error due to incompatibilities with the Camera plugin library.
Any ideas?
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:12: error: package androidx.core.app does not exist
import androidx.core.app.ActivityCompat;
^
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:13: error: package androidx.core.content does not exist
import androidx.core.content.ContextCompat;
^
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraZoo
m.java:10: error: package androidx.core.math does not exist
import androidx.core.math.MathUtils;
^
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:45: error: cannot find symbol
ActivityCompat.requestPermissions(
^
symbol: variable ActivityCompat
location: class CameraPermissions
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:58: error: cannot find symbol
return ContextCompat.checkSelfPermission(activity, permission.CAMERA)
^
symbol: variable ContextCompat
location: class CameraPermissions
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraPer
missions.java:63: error: cannot find symbol
return ContextCompat.checkSelfPermission(activity, permission.RECORD_AUDIO)
^
symbol: variable ContextCompat
location: class CameraPermissions
/Users/radsen/flutter/.pub-cache/hosted/pub.dartlang.org/camera-0.8.1/android/src/main/java/io/flutter/plugins/camera/CameraZoo
m.java:41: error: cannot find symbol
final float newZoom = MathUtils.clamp(zoom, DEFAULT_ZOOM_FACTOR, this.maxZoom);
^
symbol: variable MathUtils
location: class CameraZoom
7 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
[ +7 ms] Exception: The plugin camera could not be built due to the issue above.
That is a problem with SDK vs plugin compatibility
Go to your build.grade file and check those:
android {
compileSdkVersion 30 // must be 30 for compatibility
defaultConfig {
applicationId "tv.digicash"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Check those too in Android Studio at your File > Project Structure (Project and SDKs left menus)
They must be 30 or superior

Ionic build fails - cordova-plugin-fcm-with-dependecy-updated

Task :app:compileReleaseJavaWithJavac FAILED
/app/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
^
/app/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:137: error: cannot find symbol
#RequiresApi(Build.VERSION_CODES.LOLLIPOP)
^
symbol: class RequiresApi
location: class IonicWebViewEngine.ServerClient
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
after installing cordova-plugin-fcm-with-dependecy-updated
After removing webview plugin build was successful.

Getting this exception while running flutter app for Android

Can anybody tell me what to do about these error. Everything is working fine when I run the same app on ios. For android I am getting the below exception. One error is plugin not found. Another one is some compilation issues.
Plugin project :firebase_auth_web not found. Please update settings.gradle.
Plugin project :firebase_core_web not found. Please update settings.gradle.
Plugin project :cloud_firestore_web not found. Please update settings.gradle.
Note: /Users/daljitsingh/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.7/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/daljitsingh/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/daljitsingh/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:73: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA = 2353;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/daljitsingh/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:74: error: cannot find symbol
#VisibleForTesting static final int REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION = 2354;
^
symbol: class VisibleForTesting
FAILURE: Build failed with an exception.
Update the Android Integration part of each of these plugins pub page: https://pub.dev/packages/firebase_auth ...