Error in compilation with Geolocator pluggin - flutter

I'm getting the current error when compiling a project with Geolocator pluggin:
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-2.0.0\android\src\main\java\com\baseflow\geolocator\location\LocationMapper.java:29: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
^
symbol: variable S
location: class VERSION_CODES
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-2.0.0\android\src\main\java\com\baseflow\geolocator\location\LocationMapper.java:30: error: cannot find symbol
position.put("is_mocked", location.isMock());
^
symbol: method isMock()
location: variable location of type Location
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':geolocator_android:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
I have already created another project to test if the error would occur, and when importing the package, the error occurs as well. I followed the gradle.properties configuration
and set the compileSdkVersion to 30 and checked the Flutter Doctor too, everything is ok, but the error still persists. Does anyone know what might be causing this?

I had the same trouble with geolocator 7.7.0. Here
To fix it, I changed in build.gradle compileSdkVersion from 29 to 31. That works for me.
android {
compileSdkVersion 31
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
...
}
...
}

Try to change the targetSdkVersion and the compileSdkVersion to 31.
Don't forget to check this:
app/src/build.gradle:
minSdkVersion 20
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
I hope to help you!

In my case I changed the compileSdkVersion to 30.
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
}
}
You should pin the geolocator to version 7.6.2 (without using the caret ^ character) like so:
geolocator: 7.6.2
If you don't Flutter will still upgrade the geolocator plugin to version 7.7.0. More information can be found here: https://dart.dev/tools/pub/dependencies#caret-syntax

I had same problem, i fix with download platform version sdkmanager "platforms;android-31", and change compileVersion 31, minSdkVersion 21, and targetSdk 31.
android {
compileSdkVersion 31
...
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 31
...
}
}

I had the same problem after upgrade flutter to 3.0.3.
I have updated the geolocator plugin to version 9.0.0 and the problem was solved.
Now everything is working fine.

Related

[INSTALL_FAILED_OLDER_SDK: Requires newer sdk version #33 (current version is #31)]

Installation failed on android physical device.
While running initial code it runs properly but after adding webview_flutter package it requires newer sdk version.
I did following things but still getting same problem.
In build.gradle
......
android{
compileSDKVersion 33
....
defaultConfig{
minSDKVersion 33
targetSDKVersion 33
....
}
}

Share_plus plugin - Error: Call requires API level 22 (current min is 16): android.content.Intent#createChooser [NewApi]

My flutter version: Flutter 3.0.0
Gradle version: Gradle 7.2
when I run .../android$ ./gradlew clean and then .../android$ ./gradlew build -warning-mode all in terminal, I get the following error:
> Task :share_plus:lintDebug FAILED
Lint found 4 errors, 3 warnings. First failure:
/home/my-name/.pub-cache/hosted/pub.dartlang.org/share_plus-6.2.0/android/src/main/kotlin/dev/fluttercommunity/plus/share/Share.kt:68: Error: Call requires API level 22 (current min is 16): android.content.Intent#createChooser [NewApi]
Intent.createChooser(
I changed minSdkVersion like the following but it is still not working.
android/app/build.gradle:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.citymarker"
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
android/local.properties:
sdk.dir=/home/my-name/Android/Sdk
flutter.sdk=/home/thiago/development/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=23
flutter.targetSdkVersion=33
flutter.compileSdkVersion=33
I tried everything I could, but nothing is working.
I solved using a lower version of share_plus plugin. Just add the below line in your pubspec.yaml under dependencies:
share_plus: 4.0.2
I don't know yet why the error was happening even after changing minSdkVersion to 23. If someone has an answer, please, share with us.
under External Libraries you can find all the libraries u r using including share_plus (these are the files generated when u run 'flutter pub get'). U need to update share_plus/android/build.gradle with minSdkVersion 23, and it should build.enter image description here

One or more plugins require a higher Android SDK version error occurs when i run the project

One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\Users\Najeeb Khan\Desktop\codecanyon-30196044-single-market-groceryfoodpharmacy-androidiosadmin-panel-full-app-solution-with-web-site\Market_v2.1.2\customerApp\android\app\build.gradle:
android {
compileSdkVersion 31
...
}
It clearly says that the third-party plugin used in your project (pubspec. yaml) works only on complileSdkVersion 31. Go to your android/app/build. Gradle and change it to compileSdkVersion to 31 or 32. It will work.
Change compileSdkVersion to 32 if it is 31 in
android\app\build.gradle
The error I got was like this:
One or more plugins require a higher Android SDK version. Fix this
issue by adding the following to
C:\xxx\xxx\project_name\android\app\build.gradle:
android {
compileSdkVersion 33
...
}
In C:\xxx\xxx\project_name\android\app\build.gradle
android {
compileSdkVersion 33// flutter.compileSdkVersion
...
}
Comment out the old code and type 33
implementation 'com.google.android.material:material:33'

Could not determine the dependencies of task ':agora_rtc_engine:compileReleaseKotlin'

After upgrading to agora_rtc_engine 5.0.0 I'm experiencing the following build error:
Command: flutter build appbundle
Error message:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':agora_rtc_engine:compileReleaseKotlin'.
> Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
This is the setup in my build gradle:
defaultConfig {
applicationId "com.MyPackage"
minSdkVersion 24
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
I tried uninstalling and reinstalling build tools, upgrading gradle version, but no luck. Anyone experiencing the same issue?
In the meantime I'm downgrading to 4.2.1 as I'm not in need of any new feature, but eventually I'll need to update.
Try changing your targetSDKVersion to 31

Missing compileSdkVersion for google mobile ads

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.ringit2"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Here is what I found on my build.gradle and I can't find compileSdkVersion which I have to change to at least 28 in order for google mobile ads to operate.
After I added google_mobile_ads: ^1.1.0 on pubspec.yaml and imported the package to the main.dart, The app opens as I run the simulator but shuts down right away. Console shows me this message and it is stuck just like this forever.
Launching lib\main.dart on SM G950N in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Please note that my ext.kotlin_version is '1.6.10' because people have recommended to upgrade it
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Also changed the distributionUrl...
Not sure why google mobile ads package is so hard to use even just to start but what should I change to use it?
I am also using kotlin version '1.6.10' and compilesdk version is inside android>app>build.gradle
The compileSdkVersion will be inside
android>app>build.gradle
inside that you can see compileSdkVersion in line 30
Also check your environment path of flutter