Set Android minSdkVersion for Flutter & Pub - android

Is it possible to configure a Flutter app with a minimum Android SDK Version such that pub wont try and install dependency that require a higher android sdk version?
I've cloned a few repositories such as https://github.com/stonega/tsacdop and https://github.com/Teifun2/nextcloud-cookbook-flutter.
These have dependencies in pubspec.yaml like
dependencies:
flutter:
sdk: flutter
#for app key
url_launcher: ^6.0.3
When I execute flutter run I end up with error messages like:
Warning: The plugin path_provider_android requires Android SDK version 31.
Warning: The plugin url_launcher_android requires Android SDK version 31.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to /projects/sandbox/tsacdop/android/app/build.gradle:
android {
compileSdkVersion 31
...
}
In my case I want to use the app on Android 11 (SDK Version 30), so updating the minimum version isn't the solution I'm looking for. Though I did follow How to change Android minSdkVersion in flutter project, but configuring android/app/src/build.gradle as suggested did not work:
defaultConfig {
// setting these did NOT fix the compile errors
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
}
I've tried setting dependency to an explicit version in the pubspec.yaml file, which fixes some of the dependencies as a one-off, but it would be nice to find a universal solution.

Just assign your required SDK versions Like below. this will solve your compile error.
defaultConfig {
minSdkVersion 31
targetSdkVersion 31
}
or you can change flutter.minSdkVersion and flutter.targetSdkVersion directly from flutter>packages>Flutter_tools>gradle>flutter.gradle
https://stackoverflow.com/a/71440248/10936691

Related

Xml Suggestions not getting after change compileSdk & targetSdk to 33

I am getting some issue while updating compilesdk and targetsdk to 33.
And if I set compilesdk or targetsdk to 32, 31 or less, I get another library support issue during compilation, as described below...
1. Dependency 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.0-alpha02' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.1 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
and getting this same issue with all newly added library to the gradle
I'm not sure if this is a sdk 33 or library issue.
I already tried this--->https://stackoverflow.com/questions/30684613/android-studio-xml-editor-autocomplete-not-working-with-support-libraries/54007742#54007742
Please Refer this link. There is issue in Android Studio Chipmunk Version. Google Team fixed in Android Studio Dolphin. Check Issue Tracker as well
Replace
def lifecycle_version = "2.6.0-alpha02"
with
def lifecycle_version = "2.4.0-rc01"
in build.gradle(app) file.
Please refer to this link for screenshot.

Warning: The plugin permission_handler_android requires Android SDK version 33

I just started seeing the following warning when building my Flutter project:
Warning: The plugin permission_handler_android requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\Users\roger\Source\choon\player\android\app\build.gradle:
android {
compileSdkVersion 33
...
}
My build.gradle contains the following:
android {
compileSdkVersion flutter.compileSdkVersion
...
What caused this, and how can I fix it?
This was caused by a recent change to the permission_handler plugin; see the Changelog:
BREAKING CHANGE: Updated Android compileSdkVersion to 33 to handle the new POST_NOTIFICATIONS permission.
The official Build Numbers only go up to API Level 32 (Android 12L), but apilevels.com shows that API Level 33 is Android 13 Beta.
You have two options:
Change compileSdkVersion flutter.compileSdkVersion to compileSdkVersion 33, which targets Android SDK 33. You can also do this by writing flutter.compileSdkVersion = 33 after the existing apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" line. At the time of this answer (Flutter 3.0.2), flutter.compileSdkVersion is 31.
Roll back to permission_handler 9.x, by editing pubspec.yaml as follows:
dependencies:
...
permission_handler: ^9.2.0
...

React Native App crashes on android 11 on launch without giving error

this is my build.gradle setting and this is my system info
I'm trying to run the react native app on android 11 but it is keep crashing on launch without giving any error I have tries almost every solution including setting in build.gradle
buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "30.0.0"
ndkVersion = "20.1.5948944"
multiDexEnabled = true
setting ** target API to"30" ** in AndroidManifest.xml
the Gradle version I'm using is
Gradle plugin version is 4.1.3
Gradle version is 6.7**
please help me find the solution in this regard thanks
I got an error like this when setting targetSdk version to 30 it's happening because of okhttp version and fixed it by using the latest version
implementation("com.squareup.okhttp3:okhttp:4.9.1")
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1")
add this in your android/app/build.gradle
This answer has been provided by manohar-octifi (github discussion):
If you are using #sentry/react-native and the version is lower than 2.0.0, then update the version to 2.0.0 or higher (I updated to 2.2.0). This should fix the problem.

Adding React-Native-Admob in React-Native

I am trying to add React-Native-Admob 2.0.0-beta.5 into React-Native v0.55.4 for Android.
compileSdkVersion =26
buildToolsVersion ="27.0.3"
targetSdkVersion = 26
supportLibVersion = "26.1.0"
minSdkVersion = 18
And React-Native-Admob has
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
}
And when i Compile the error Exception occur
The SDK Build Tools revision (23.0.1) is too low for project ':react-native-admob'. Minimum required is 25.0.0
I can't downgrade my project's SDK, other package uses that SDK.
You don't need to downgrade, you need to upgrade. Dependencies were probably added in the SDK that admob relies on. You can download the specified version packages for the SDK through Android studio and then set your SDK version in the file to the appropriate version necessary for admob.
Edit
I see that you are saying that admob is using version 23. You may need to submit an issue with them on GitHub for this.
you can change the buildToolVersion of the library you are using, just go to -> node_modules/{your-library}/android/build.gradle, change buildToolsVersion from 23.0.1 to 25.0.0.
if the studio asks for any updates regarding build, just update it, and it might work.
another solution:
although I haven't tried it, it has a lot of emoji love on GitHub,
https://github.com/oblador/react-native-keychain/issues/68#issuecomment-304836725
Goto
"node-module/react-native-admob/android/build.gradle" file, then change the compileSdkVersion and buildToolsVersion to following values
compileSdkVersion 27
buildToolsVersion "27.0.3"

The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25; please update

I am getting this error on the latest version of Android Studio and while I have installed both Android SDK Platform API 25 and Android SDK Build-Tools 25.
As Vishnu said, For me updating Android studio and Gradle didn't fix the problem.
I navigated to Tools -> Android -> SDK Manager and selected BuildTools and checked for the updates related to platform tools. After updating and installing those, fixed my problem.
And for one my friends, the issue got resolved after following the above steps and then navigating to Help->Check for updates-> and installing all the available updates.
Attached Screenshot for the same.
I am facing similar issue after upgrading Android Studio to 3.0. A very simple way to fix this is go to
Tools -> Android ->SDK Manager -> SDK Tools
There look for Android SDK platform tools and update it. (Screenshot attached)
Thats it, you don't have to change any other gradle setting.
I had a similar problem. Updating Android Studio to version 2.2.2 (latest at the time of this writing) and Gradle version to 2.2.2 (latest at the time of this writing) in project_name/build.gradle file fixed this issue.
For reference, this is my config in project_name/app/build.gradle file:
minSdkVersion = 19
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = "25"
supportLibraryVersion = "25.0.0"
And this is my dependencies in project_name/build.gradle file :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Open AndroidMainfest.xml
Click the red icon => Disable inspection => Error is gone
I face same problem but when I swap
buildToolsVersion "25.0.0"
to first line then problem solved. Then the final app grade become:
android {
buildToolsVersion "25.0.0"
compileSdkVersion 25
defaultConfig {
applicationId "com.***"
minSdkVersion 15
targetSdkVersion 25
versionCode 0
versionName "0.0.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Update your android sdk platform-tools to the revision from 24.0.4 to 25.x.x on sdk manager. Then android studio click File->Invalidate Caches/Restart...
The error must be gone now.
Try to update
Android SDK Build-Tools
Android SDK Platform tools
Android SDK Tools
Android Support Repository
Google Play Services
Google repository
etc to the latest version. Error must be gone.
Go to Gradle(app) and replace
buildToolsVersion "25"
to
buildToolsVersion "24.0.4" // Or Latest installed gradle version
also if targetSdkVersion is 25 then make this 24
On command line
./sdkmanager "platform-tools" "platforms;android-26"
./sdkmanager --list
Check if you have update to latest release

Categories

Resources