Execution failed for task ':sms:verifyReleaseResources' while building APK of flutter application - flutter

I'm trying to build APK of my flutter application but upon running flutter build apk --split-per-abi I'm getting below error.
It looks like there is something wrong with the camera package and I don't know what sms:verifyReleaseResources is referring to. I have tried different verisons of camera package but in vain.
Did any one else encountered this issue before?
I have followed this guide to build an apk
https://flutter.dev/docs/deployment/android
D:\CIIT GUIDE\Flutter\Apps\storeifie_new_admin_panel>flutter build apk --split-per-abi
Parameter format not correct -
Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
Removed unused resources: Binary resource data reduced from 719KB to 693KB: Removed 3%
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sms:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\faiza\.gradle\caches\transforms-2\files-2.1\44b1706abe044cd42dcac5be863451ed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\faiza\.gradle\caches\transforms-2\files-2.1\44b1706abe044cd42dcac5be863451ed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 1m 8s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 69.4s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve
the incompatibility.
Building plugin camera...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 5.3s
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'camera'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
* 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 4s
The plugin camera could not be built due to the issue above.
Directory looks like this
And below is my key.properties
storePassword=xxxxxx
keyPassword=xxxxxx
keyAlias=key
storeFile=key.jks
android/app/build.gradle file
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.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.appName"
minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.multidex:multidex:2.0.1'
}
android/build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google() // Google's Maven repository
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build directory

I was able to solve this problem by simply removing below packages from pubspec.yaml
otp: ^2.2.3
flutter_otp: ^0.3.2

Related

flutter build apk --release not working after flutter 3.3.10

After Upgrading flutter to 3.3.09 and then to .10 The Release Build Only Stopped Working With Problems In Local Notifacations Package, After Many Many Many Edits In Gradle And Kotlin I Stopeed The Error From The Package And A New Error Pops-up
I've Tried Every Possible Gradle.Wrapper , Gradle , Kotlin Combination And Allways there is a Compatability Problem, Checked Here And Here And Here To Try To Get A Possible Working Combination With No Luck, And No Fix Found On Stack overflow Helped.
android/gradle
buildscript {
ext.kotlin_version = '1.5.32'
repositories {
google()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
google()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/gradle
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.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services' //this line
android {
compileSdkVersion 33
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.laamarRose.laamar_distribution"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled 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
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'androidx.multidex:multidex:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics'
}
gradle-wrapper.properties
#Fri Jul 09 02:12:26 EEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
The Error
* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> Compilation error. See log for more 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 15m 52s
Running Gradle task 'assembleRelease'... 955.0s
┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │
│ D:\LaamarRose\Projects\Trust-Fund\trustfundapp\android\build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘
I Would Like To Get The Release Build Working Again Without Deleting Anymore Packages
Tried Multiple Stackoverflow Solutions And Google And Other Scources No Luck
Edit #1
When Setting The ext.kotlin_version = '1.6.10' Got This
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not delete old build\app\reports\lint-results-release-fatal.html
Trying A Secound Time Showed This Error `
Could not resolve all artifacts for configuration ':flutter_local_notifications:debugUnitTestRuntimeClasspath'.
Please try to change your Kotlin Version hope its help to you. and rebuild again flutter build apk --release command, I just test on my machine
form
ext.kotlin_version = '1.5.32'
to
ext.kotlin_version = '1.6.10'
after succeful build result
Running Gradle task 'assembleRelease'... 122.9s
√ Built build\app\outputs\flutter-apk\app-release.apk (42.6MB).
Try doing flutter build apk only. It generates app-release.apk also.
Location: build/app/outputs/flutter-apk/app-release.apk
I'm also using flutter v3.3.10. Works for me.
Edit:
I use ext.kotlin_version 1.7.20 as mentioned below. Maybe you need to update your build.gradle to a newer version. Also replace jcenter() with mavenCentral() as JCenter Maven repository is no longer receiving updates.
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.14' // this is for firebase
}
}
Also do flutter clean and invalidate and clear caches of your IDE, before building release apk.

Flutter/Dart error: Execution failed for task ':app:checkDebugAarMetadata'

I recently went back to my old flutter project and updated a bunch of things because I was getting errors. Now I'm getting the error below. I have been on it for at least 3 days and have tried a bunch of different things, but I still can't seem to find the solution. Any help is much appreciated. I have also included the build.gradle files below:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.google.android.gms:play-services-location:16.+.
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
* 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 18s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Exception: Gradle task assembleDebug failed with exit code 1
Below is my android\build.gradle:
buildscript {
ext.kotlin_version = '1.4.20'
repositories {
google()
//jcenter()
mavenCentral()
maven { url "https://maven.google.com/"}
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:' + String.valueOf(kotlin_version)
}
}
allprojects {
repositories {
google()
//jcenter()
mavenCentral()
maven { url "https://maven.google.com/"}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my app\build.gradle:
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 FileNotFoundException("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.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "[id here]"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled 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 'com.google.firebase:firebase-analytics:20.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.android.gms:play-services-ads:20.5.0'
}
There seems to be a reoccurring issue with the bintray repository, To fix the issue, I followed this really helpful solution: https://stackoverflow.com/a/70319873/13843688
Everything is now working as expected.

Mistakes happen when building Flutter APK

Hello I just Finished Programing using Flutter platform So when I was write my code and running the code everything working well But when i need to Building APK show my Error and cant Building i don't no what's the problem and How can i Fixed
please any Body help my
This is the Error that Showing**
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unique_identifier:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Ahmed\.gradle\caches\transforms-2\files-2.1\aafef0879a74786e0e084911877b2a52\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\Ahmed\.gradle\caches\transforms-2\files-2.1\aafef0879a74786e0e084911877b2a52\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 14m 8s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 851.9s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve
the incompatibility.
Building plugin cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
Running Gradle task 'assembleAarRelease'...
This is my Bulid.Gradle
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 FileNotFoundException("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.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.Biz.appExit.docFlow"
minSdkVersion 19
multiDexEnabled true
targetSdkVersion 29
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
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
implementation 'com.google.android.gms:play-services-basement:17.5.0'
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
As you can read in error message, the plugin you used has some AndroidX incompabilities. Try to execute flutter packages get and flutter clean, maybe something cached. Then try build again.
Also look at this link How to fix flutter AndroidX incompatibility?

Flutter: Cannot build android apk

I have been getting errors building apk for flutter. But the app works well while I run it.
I have tried so many fixes like migrating to androidX and upgrading my dependencies but none worked. I recently started getting this error after upgrading flutter. What could be the solution to this?
Error
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':shared_preferences:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/apple/.gradle/caches/transforms-2/files-2.1/d45c258d5b0086b06365ac1a25df0442/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/apple/.gradle/caches/transforms-2/files-2.1/d45c258d5b0086b06365ac1a25df0442/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':path_provider:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/apple/.gradle/caches/transforms-2/files-2.1/d45c258d5b0086b06365ac1a25df0442/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/apple/.gradle/caches/transforms-2/files-2.1/d45c258d5b0086b06365ac1a25df0442/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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.gradle
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.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.miraclecentre.bnotion.ben.maf_mentor"
minSdkVersion 16
targetSdkVersion 29
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Try changing your targetSdkVersion to 28.
That's the only fix I've run across. But when I figure out why that is, I'll come back and update.
EDIT:
update your shared_pref version reference to the most recent one.
After that's done run
flutter pub cache repair
try :
flutter clean
Wait for it to delete older iOS and Android build files.
Then run again:
flutter build apk
Solved this by changing build.gradle file,
Go to,
[project_folder]/external_package/flutter_plugin/[problem_causing_plugin_name]/android/build.gradle/
Change compileSdkVersion 27 to compileSdkVersion 28
then, run Flutter clean and Flutter pub get, and try to create release Apk.

How can I solve below flutter error in android studio 3.5

* Error running Gradle:
ProcessException: Process exited abnormally:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\user\AndroidStudioProjects\stop\android\app\build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'reader' for project ':app' of type org.gradle.api.Project.
* 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 17s
Command: C:\Users\user\AndroidStudioProjects\stop\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Process finished with exit code 1
Info:-
1.I have deleted IOS directory before running build apk
2.I don't know if IOS directory affect a flutter app or not
3.After trying to build apk this above error is displaying in the console box
I have added build.gradle code
//buildscript {
// ext.kotlin_version = '1.3.50'
// repositories {
// google()
// jcenter()
// }
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Local.properties
sdk.dir=C:\\Users\\user\\AppData\\Local\\Android\\Sdk
flutter.sdk=C:\\Users\\user\\flutter
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.buildMode=release
app/build.gradle
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.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ramram.quit"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
I have added build.grale and local properties please help now...
Below code is the latest error
* Error running Gradle:
ProcessException: Process exited abnormally:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\user\AndroidStudioProjects\stop\android\build.gradle' line: 30
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method classpath() for arguments [com.android.tools.build:gradle:3.5.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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 1m 15s
Command: C:\Users\user\AndroidStudioProjects\stop\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.