How to update minSdkVersion in flutter updated 2.8? - flutter

Before updating to Flutter 2.8
defaultConfig {
applicationId "com.kim.app"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
After updating to Flutter 2.8:
defaultConfig {
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
How can I update minSdkVersion higher? I cannot find the target "flutter.minSdkVersion" variable anywhere.

Go to android/local.properties
Add the following ie define the versions
flutter.minSdkVersion=21
flutter.targetSdkVersion=30
flutter.compileSdkVersion=30
Once done goto android/app/build.gradle and add the following
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
Then goto android/build.gradle
Update the Kotlin version
ext.kotlin_version = '1.6.0'

just replace flutter.minSdkVersion with your value ,
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

Just replace flutter.minSdkVersion to your target version.
flutter.minSdkVersion is found in
https://github.com/flutter/flutter/blob/stable/packages/flutter_tools/gradle/flutter.gradle

Related

Your project requires a newer version of the Kotlin Gradle plugin

i have already tested latest version of kotlin 1.8.20-Beta ,1.8.10 and 1.7.10 also my app breaks.
The binary version of its metadata is 1.8.0, expected version is 1.6.0
i leady added a jetifier in android.enableJetifier=true
Android studio is updated
my build.gradle file is?
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ahmadpro.tplayer"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled = true
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation("com.android.support:multidex:2.0.1")
}

A problem occurred evaluating project ':app' . No signature of method

Recently, I studied using firebase in a flutter project. I followed the step but also got an error.
I searched and guess it is a app\build.gradle getting a problem. But also didn't know what the problem is.
No signature of method: build_5viubdggwtiixi0imz59oppqn.android() is applicable for argument types: (build_5viubdggwtiixi0imz59oppqn$_run_closure2) values: [build_5viubdggwtiixi0imz59oppqn$_run_closure2#71088475]
Here are the "relevant codes and error:
Error:
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\firebase\android\app\build.gradle' line: 29
* What went wrong:
A problem occurred evaluating project ':app'.
> No signature of method: build_5viubdggwtiixi0imz59oppqn.android() is applicable for argument types: (build_5viubdggwtiixi0imz59oppqn$_run_closure2) values: [build_5viubdggwtiixi0imz59oppqn$_run_closure2#71088475]
* 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 1s
Exception: Gradle task assembleDebug failed with exit code 1
Code:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.getx.app.db.firebaseApp"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
MultiDexEnable true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
#lousea, We get such kind of error when we use any undefined attribute in the gradle file.
In your case, in the default config, you have misspelled the multidex attribute. Just change MultiDexEnable to multiDexEnabled then it will work properly.
or just replace the defaultConfig from below
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.getx.app.db.firebaseApp"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

Build failed with an exception using flutter flavors

When I use the Flutter flavor the app gets an error
My app/build.gradle
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.insurance_admin"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
flavorDimension "flavor"
productFlavors{
prod{
dimension "flavor"
resValue "string","app_name","Admin Prod"
applicationIdSuffix ""
}
qa{
dimension "flavor"
resValue "string","app_name","Admin QA"
applicationIdSuffix "-qa"
}
dev{
dimension "flavor"
resValue "string","app_name","Admin Dev"
applicationIdSuffix "-dev"
}
}
}
error throw in line 28
I Have already used Flutter doctor, it perfectly works on google chrome but it doesn't support mobile and emulator
attach my errors
I don't use any other firebase JSON files
attach my project folder

flutter : Execution failed for task ':app:mergeDexDebug'

my apk won't get excuted causing this problem . My project is a brand new one, but having problems running the app on my device ( Note :#: i did add to my depencecies multidex and it didn't work
implementation 'com.android.support:multidex:2.0.1')
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
// applicationId "com.example.yumor"
// minSdkVersion 19
// minSdkVersion flutter.minSdkVersion
// targetSdkVersion flutter.targetSdkVersion
// versionCode flutterVersionCode.toInteger()
// versionName flutterVersionName
multiDexEnabled true
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
~~~!
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform classes.jar (project :sqflite) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=19, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: C:\Users\Abdou\flutter project\realfultter\yumor\build\sqflite\intermediates\runtime_library_classes_jar\debug\classes.jar.
> Unable to read jar file C:\Users\Abdou\flutter project\realfultter\yumor\build\sqflite\intermediates\runtime_library_classes_jar\debug\classes.jar
If this is set to 20 or lower, you need to configure your app for multiDex support.
defaultConfig {
applicationId "com.inspire.aaym"
minSdkVersion 21
targetSdkVersion 30
}
So, if your app is not intended to be used in the Android version prior to 5.0, setting the minSdkVersion number to 21 will easily fix this issue.

how to fix Cannot resolve symbol 'GradleException'?

So im using an old sdk version which is "Android API 21 Platform" because I'm only trying to make a simple application for my school project, and I want to add google maps to my flutter app which needs for minSdkVersion to be changed to 20
while my build.gradle file looks like this:
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.untitled"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
so is it possible to stick with this sdk version to fix this problem or do I need to upgrade to the latest sdk version?