Reputation: 123
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.
Upvotes: 4
Views: 33056
Reputation: 11
try going to android/gradle folder then find the wrapper and edit it to the latest version e.g 7.6-bin ,then go to app gradle and rename the kotlin version to 1.7.0 and the build tools to 7.4.0 like this.
distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-7.6- bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
buildscript { ext.kotlin_version = '1.7.0' repositories {
google()
mavenCentral() }
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
Upvotes: 0
Reputation: 921
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.
Upvotes: 0
Reputation: 187
buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
Upvotes: 0
Reputation: 451
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
Upvotes: 5
Reputation: 11
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.
Upvotes: 1
Reputation: 6867
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.
Upvotes: 1