Android Gradle Issue - Flutter / Dart - android

I have a problem with my Gradle Sync.
I use IntelliJ and Android Studio to build a Flutter / Dart App.
I added 2 new dependencies and now i have an issue with Gradle.
In Android Studio all works fine (The Gradle Sync finishes without failures or warnings), but in IntelliJ it is not working.
* Error running Gradle: Exit code 1 from: C:\Users\stesc\Documents\Programming\timecoder-flutter\android\gradlew.bat app:properties: NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\stesc\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
BUILD FAILED
Total time: 4.669 secs
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\stesc\Documents\Programming\timecoder-flutter\android\build.gradle' line: 25
* What went wrong: A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'. Finished with error: Please review your Gradle project setup in the android/ folder.
> A problem occurred configuring project ':shared_preferences'.
> Could not resolve all dependencies for configuration ':shared_preferences:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :shared_preferences
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

1. Update your gradle version from project -> android -> build. For me :
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
2. Use latest sdk tool version
3. Open terminal from Tools->Flutter and run these following commands
flutter upgrade
flutter doctor

Make your allpojects->repositories same like buildscript->repositories
If the problem still persists check if your project and shared_preferences both uses the same gradle version. If not, then you may need to make few changes in either your project or in shared_preferences project.

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.0"
}
}
}
}
It fixed for me by adding this to my build.gradle in android folder.

yaa It had solved for me..!
Just go to flutter sdk folder and go to this path \flutter\packages\flutter_tools\gradle\flutter.gradle
and in flutter.gradle file change from this code
buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}

I had the same problem and solved it too.
Perhaps, will be useful for someone.
This was my problem:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/abc/Desktop/user/project/android/app/build.gradle' line: 14
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.4.1. If using the gradle wrapper, try editing the distributionUrl in
/Users/abc/Desktop/user/project/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-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 8s
Command: /Users/abc/Desktop/user/project/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
I went to gradle-wrapper.properties and changed this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
The problem was solved.

Related

flutter problem gradle 7.4\scripts\emabqxituwovfmtng117ez4xf

what should i do if in flutter error like this?
* Where:
Build file 'D:\StudioProjects\dindiksbynew\android\app\build.gradle' line: 26
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not open dsl generic class cache for script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' (C:\Users\RRHP\.gradle\caches\7.4\scripts\emabqxituwovfmtng117ez4xf).
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* 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 43s
Exception: Gradle task assembleDebug failed with exit code 1
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
I've tried changing the gradle version, still can't, please help
been faced this issue lastweek. Its quite difficult to debug. and here my current workaroud:
android>build.gradle
buildscript {
ext.kotlin_version = '1.7.20' // upgrade my kotlin version
...
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0' // change this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
doc: https://kotlinlang.org/docs/gradle.html#apply-the-plugin
latest stable kotlin version 1.7.20, maximum fully support only for gradle 7.1.1
its recommended do not use gradle above it.
next
add this line to: android>gradle>wrapper>gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
another step, maybe its required to upgrade to java sdk 11.
hope its help.

Error with Google Maps Flutter in Android Studio

I try to add google maps on flutter, I added the following dependence:
dependencies:
google_maps_flutter: ^0.5.17
and its respective api key in android and ios.
But when running the project it marks the following:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.google.android.gms:play-services-tasks' has different version for the compile (15.0.1) and runtime (16.0.1) classpath. You should manually set the same version via DependencyResolution
* 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
Finished with error: Gradle task assembleDebug failed with exit code 1
and try to add the dependencies manually in buil.gradle
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
}
and this in build.gradle in project level
apply plugin: 'com.google.gms.google-services'
but still with the same.
You probably have to migrate your project to AndroidX. I had a similar issue in my project.
Open you Android folder in Android studio, go to File -> Sync Project With Gradle Files and then Refactor -> Migrate to AndroidX

Cordova build failed : Could not find support-v4.jar

I don't know what i did but my build fail until 3 hours on android and I can't fix it ... There is the log :
ANDROID_HOME=
C:\Users\User\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is
scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action)
instead.
at.build_bxct3n5fn9ey9qgc57qreulsp.run(C:\Users\User\MyProject\application\platforms\android\build.gradle:143)
The JavaCompile.setDependencyCacheDir() method has been deprecated and
is scheduled to be removed in Gradle 4.0.
Incremental java compilation
is an incubating feature.
The TaskInputs.source(Object) method has
been deprecated and is scheduled to be removed in Gradle 4.0. Please
use TaskInputs.file(Object).skipWhenEmpty() instead.
WARNING: Module
'com.android.support:support-v4:26.1.0' depends on one or more Android
Libraries but is a jar
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'.
Could not find support-v4.jar (com.android.support:support-v4:26.1.0). Searched in the following
locations: BUILD FAILED
Total time: 1.569 secs
https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.jar
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an
exception.
What went wrong: A problem occurred configuring root project 'android'.
Could not find support-v4.jar (com.android.support:support-v4:26.1.0). Searched in the following
locations:
https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.jar
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I use (edited :)cordova-android#6.4.0 and cordova 8.1.2(cordova-lib#8.1.1)
Hope someone can help me...
Changing build.gradle repositories to use maven repository solves this issue:
allprojects {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
}
}
This file can be found on platforms/android/build.gradle.
OK THEN,
After update my gradle and set the environment variable on Windows 7 of the /bin gradle folder (yes, i didn't), upgraded Android Studio, upgraded Cordova to 8.1.2, do "cordova platform rm android" and "cordova platform add android#6.4.0" on any change i finaly found the issue.
I just uninstalled NDK in SDK Manager. For me it works, i don't know if it is for all but i finaly built my project !
Sorry for english and ty for reply all

React-Native- Failed to notify project evaluation listener

Using gradle 4.3 to build a react-native app on windows 7 and I get the below error, Not sure what the issue is, any help will be apreciated.
C:\Users\username\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\username\AwesomeProject\node_modules (62ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 0s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
Upgrade your build.gradle project file; com.android.tools.build:gradle version from 2.2.3 to use as below:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
You may or may not, also encounter this issue, please update your build tools.
The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0
Solution: update inside your project /app/build.gradle as below:
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"

cordova build android command error

while building cordova project i get the follwing error on running command cordova build android?
please help with the follwoing code
C:\Users\gaurav-s\hello>cordova build android
ANDROID_HOME=D:\adt-bundle-windows-x86-20140702\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.5.0.
Required by:
:android:unspecified
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradl
e/1.5.0/gradle-1.5.0.pom'. Received status code 407 from server: Proxy Authentic
ation Required
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 10.001 secs
Error: Error code 1 for command: cmd with args: /s,/c,"C:\Users\gaurav-s\hello\p
latforms\android\gradlew cdvBuildDebug -b C:\Users\gaurav-s\hello\platforms\andr
oid\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
Build tools have been moved from maven to jcenter. Go to your gradle settings file. Change
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
to
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
It is better to update your gradle to latest version.
This is because of gradle error Download the file
http://services.gradle.org/distributions/gradle-2.14.1-all.zip
and extract it in any of directory and set the path by open cmd and
enter
setx path (extracted direstory)/bin
after reopen cmd and check whether the gradle is works or not by give
gradle -v
it shows the gradle version output .
Now the error is fixed run
ionic build android

Categories

Resources