Flutter Error running Gradle: Exit code 1 (Ubuntu 18.04 LTS) - android-studio

My error in flutter run
SO: Ubuntu 18.08 LTS
flutter run
Launching lib/main.dart on moto g 6 play in debug mode...
Initializing gradle... 0,7s
Resolving dependencies...
* Error running Gradle:
Exit code 1 from: /home/leonardo/Github/apps-with-flutter/contador_de_pessoas/android/gradlew app:properties:
Starting a Gradle Daemon (subsequent builds will be faster)
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/leonardo/Github/apps-with-flutter/contador_de_pessoas/android/app/build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all files for configuration 'classpath'.
> Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
* 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
Please review your Gradle project setup in the android/ folder.
Executing ./android/gradlew return ok!
leonardo#cintra:~/Github/apps-with-flutter/contador_de_pessoas$ ./android/gradlew
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Task :help
Welcome to Gradle 4.4.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see a list of command-line options, run gradlew --help
To see more detail about a task, run gradlew help --task <task>
BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
Please, help me!

Resolved!
I followed the orientation of the #M.Ricciut https://stackoverflow.com/a/52947028/6899896
it worked! But I gave this error (You have not accepted the license agreements of the following SDK components) and solved it

Flutter itself is the issue. For some of the discussion about it: https://github.com/flutter/flutter/pull/23397
In short, following Mahi-K from the above link, you have to edit $flutterRoot/packages/flutter_tools/gradle/flutter.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
In the gradle wrapper properties gradle/wrapper/gradle-wrapper.properties you may also have to change it to 4.6 or above
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

Related

How to change the Version in AndroidStudio?

I get the follwing message when I want to build:
e: This version (1.0.1) of the Compose Compiler requires Kotlin version 1.5.21
but you appear to be using Kotlin version 1.5.30 which is not known to be compatible.
Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> 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 713ms
Does someone know how to change the version?
Any help is apreciated 🙏
You have to change the Kotlin version in the project-level build.gradle file:
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21'
}
And also in the app-level build.gradle file.
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'
}

android studio error: Project 'app' not found in root project and Command failed:

Q. I got two errors (Project 'app' not found in root project) and (Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081). I tried to change my port number or gradle version..etc.. but this two error keep happening :( Please help me I'm soooo exhausted.
//This is my version
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
classpath("com.android.tools.build:gradle:3.2.0")
classpath 'com.google.gms:google-services:4.0.1'
gradleVersion = '4.6'
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
//settings.gradle
rootProject.name = 'keynoti'
include ':app'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
// This is my error explanation
FAILURE: Build failed with an exception.
* What went wrong:
Project 'app' not found in root project 'keynoti'.
* 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 23s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Try to clean project and rebuild project in Android Studio IDE, if it doesn't work, rebuild from react native.
i had the same issue.
what worked for me was that i added a file( settings.gradle) and you should add
one line in it:

I create new app in flutter with flutter create AppName in vs code terminal it worked but when i try flutter run it shows this error message

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
AAPT: error: failed writing to 'C:\Users\Mii_Ranna\Desktop\vs test\projectname\build\app\intermedias invalid. (13).
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log o
Get more help at https://help.gradle.org
BUILD FAILED in 3m 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 190.1s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Je
Building plugin integration_test...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 9.2s
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':compileReleaseAidl'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting ty setting tpath in your project's local properties file at 'C:\src\flutter\packages\integration_test\anhe sdk.dir path in your project's local properties file at 'C:\src\flutter\packages\integrat hion_test\an
droid\local.properties'.
Try: o
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':compileReleaseAidl'.
SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or b
y setting the sdk.dir path in your project's local properties file at 'C:\src\flutter\packag
es\integration_test\android\local.properties'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to ge
t more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 6s
Exception: The plugin integration_test could not be built due to the issue above.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log o
utput. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 6s
Exception: The plugin integration_test could not be built due to the issue above.
Make sure you have Androidx enabled.
android.useAndroidX=true
Make sure the classpath is set properly.
classpath 'com.android.tools.build:gradle:3.5.0'

How to fix exception causing flutter app to fail at launch?

I am trying to implement google admob to add advertisement to my application, but when I do I start to get exceptions. Here is the current build error I am getting
BUILD FAILED in 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 firebase_admob...
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+10\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'firebase_admob'.
> Failed to apply plugin [id 'com.android.library']
> Minimum supported Gradle version is 5.1.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+10\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.1.1-all.zip
* 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
It says line 22 of the build.gradle file, which looks like this:
apply plugin: 'com.android.library'
Any suggestions are appreciated! Thank you!
Your need to Upgrade your Gradle Version to 5.1.1
in android/gradle/wrapper/gradle-wrapper.properties
change
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip
and in android/build.gradle
under buildscript --> dependencies, change,
classpath 'com.android.tools.build:gradle:3.3.2'
to
classpath 'com.android.tools.build:gradle:5.1.1'
then try again.

Gradle Problem When Importing Flutter Project From Git

I imported a Flutter Project from this git repo: https://github.com/gligerglg/geodropin (website: https://itsallwidgets.com/geodropin) by copying the HTTPS, then go to Android Studio -> Check out Project from Version Control -> Git. When I open the project and try to run, this error appear:
* Error running Gradle:
ProcessException: Process "/Users/phuctruong/AndroidStudioProjects/geodropin/android/gradlew" exited abnormally:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/phuctruong/AndroidStudioProjects/geodropin/android/app/build.gradle' line: 45
* What went wrong:
A problem occurred evaluating project ':app'.
> For input string: "1.01"
* 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 0s
Command: /Users/phuctruong/AndroidStudioProjects/geodropin/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
I assume this has something to do with my gradle version and the project's gradle version? I'm a newbie to Flutter so my understanding of gradle is limited. When I check gradle-wrapper.property it said i'm using gradle 4.10.2
Thanks for helping.
Check out the 16th line of app/build.gradle you will see that the number in a string is of float type. VersionCode should always be integer. Check this out https://developer.android.com/studio/publish/versioning
You can remove this error by just changing it to positive integer value like this :
flutterVersionCode = '1'
Now this problem is resolved but however you will get another error related to androidX but thats different question.
Error would be :
BUILD FAILED in 10s
******************************************************************************************* The Gradle failure may have been because of AndroidX incompatibilities
in this Flutter app. See link for more information on
the problem and how to fix it.
******************************************************************************************* Finished with error: Gradle task assembleDebug failed with exit code 1
For this issue you need to migrate the project to androidX,
add it in android/gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
Or if its already there, Check this migration docs for more info.
Or nothing works, you can ask another question.

Resources