Related
I'm working on Flutter app. I can run app in the android device successfully but try to make build (.apk) file and got below issues.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_twitter:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/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.
* Get more help at https://help.gradle.org
BUILD FAILED in 5m 2s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 303.8s (!)
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_messaging...
The plugin firebase_messaging could not be built due to the issue above.
Below are project's stuffs
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.xxxx.eeee"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
> local.properties
sdk.dir=/Users/ipatel/Library/Android/sdk
flutter.sdk=/Users/ipatel/Documents/Amit/FlutterSetup/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.ver
My app is compatible with AndroidX and also tried with many solution but can't able to fix my issue.
I checked
- https://github.com/roughike/flutter_twitter_login/issues/29
- A failure occurred while executing com.android.build.gradle.internal.tasks
- flutter Error "Android dependency 'androidx.core:core' has different version" using flutter_local_notifications and location packages
and others.
Flutter Doctor Result:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.3 18D109, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (4 available)
build.gradle
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.xxxx.aaaa"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
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
}
}
}
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
~PS : Let me know if you want more details from my end.
The issue is some library is not compatible or not using androidx while others are. Thanks to google for transferring all support lib to androidx now many libraries having conflicts like this and I mostly go to debug around which lib has an issue like commenting and uncommenting the lib from pubspec.
Assuming the flutter_twitter plugin was the issue.
As we can check that, that twitter plugin not using AndroidX link so we need to change it our self.
(all these changes needs to be changed in twitter plugin, not flutter project)
I think you can change the gradle.properties to use androidx and also compile version to 28
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
add this two lines, change gradle classpath
classpath 'com.android.tools.build:gradle:3.5.3'
and compileSdkVersion 28 in flutter_twitter.
I am able to generate release build using that plugin.
Ohh yah you can find your cached version of plugin at /Users/parth.dave/.pub-cache/hosted/pub.dartlang.org/flutter_twitter_login-1.1.0/ something like this where you can update it. or either open android folder in androidstudio and studio will show you two projects app and twitter where you can update this things.
also sometimes it's better to open android project in android studio and update all things from which you might get errors before running flutter projects.
Problem is with Execution failed for task ':flutter_twitter:verifyReleaseResources'.
i found link for this issue
flutter_twitter_login/issue #12
Add this dependency in your pubspec.yaml file and let me know this working or not?
flutter_twitter_login:
git: git://github.com/eudangeld/flutter_twitter_login.git
Goto the android studio external libraries in the left side
--> select the library that cause this issue
--> then goto the android -> build.gradle and update the compileSdkVersion to 28
You need to update the compileSdkVersion of the flutter_twitter module to 28 :
1/ In your flutter project, locate your "android" folder and open it as an android project in Android Studio.
2/ Expand "Gradle Scripts" and wait for it to load.
3/ Locate "build.gradle (Module: flutter_twitter)"
4/ Modify the compileSdkVersion from 27->28.
5/ Save the changes.
My build worked after that.
The answer was here : https://github.com/flutter/flutter/issues/32595
thank you, it worked for me for device_id: ^0.1.3
plugin conflit with cloud_firestore: ^0.13.4+2
In your flutter project, locate your android folder and open it as an android project in Android Studio.
Expand Gradle Scripts and wait for it to load.
Locate build.gradle (Module: device_id)
Modify the compileSdkVersion from 27 -> 28.
Save the changes.
I faced a similar issue and here is how I fixed it by following this link.
In Android Studio (with your project open) right-click the android folder, and click "Flutter"->"Open Android Module in Android Studio". Select "Open in New Window"
In the new window, Wait for Gradle to finish the sync
Expand "Gradle Scripts"
Locate "build.gradle (Module: flutter_twitter)" or which so ever package is throwing the error
Modify the compileSdkVersion from 28->29 (or whatever is defined in your android/app/build.gradle file).
Save the changes and run flutter clean
Build the signed apk.
seems like your firebase_messaging library version does not support AndroidX support. Make sure you have updated version of this library.
dependencies:
firebase_messaging: ^6.0.9
I had the same problem before and it took almost a half day to find a solution.
My project compileSdkVersion was already 28 but in my case app-usage package compileSdkVersion was under 28 and i had to change it manually in
/home/"user"/.pub-cache/hosted/pub.dartlang.org/"package with problem"/android/build.gradle.
and it solved the problem.
I'm starting developing apps with flutter, and I encounter with this error when I clone a project from GitHub:
What went wrong?
Execution failed for task ':app:preDebugBuild'.
Android dependency 'androidx.appcompat:appcompat' has different version for the compile (1.0.0) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution
I'm running Android Studio 3.2.2 and Flutter SDK 1.2.1
You need to migrate the project to Android X. You can only do this through Android studio 3.3.
Follow the procedures here to Migrate your Project to Android X
Finally i found a solution for the problem.
Only need to add the following code on the build.gradle file:
configurations.all {
resolutionStrategy {
force 'androidx.media:media:1.0.0'
}
}
Then, the app runs without any error.
Following is the build.gradle code in Android Studio
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.sg.blahblah"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
lintOptions {
checkReleaseBuilds true
abortOnError false
xmlReport true
htmlReport true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.apps.dashclock:dashclock-api:+'
compile 'com.roughike:bottom-bar:1.4.0.1'
compile 'com.diogobernardino:williamchart:2.2'
}
I am getting the below error:
Error:A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
Can anyone please help?
Following is the Instant Run screenshot
I got this problem too. I fix it by Change build.gradle in project
Change
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
And also I change the distributionUrl in gradle-wrapper.properties(Global Version)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
And got succeed.FYI.
I am facing same error before a week I solve by disabling the Instant Run
File → Settings → Build, Execution, Deployment → Instant Run and
uncheck Enable Instant Run.
Hope it works.
Note This answer works on below Android Studio 3
you need check your gradle version. gradle -v
then you should know your gradle version and your gradle plugin version compatible.
Example:
gradle 4.6 is not compatible with gradle plugin 2.2.
so need update com.android.tools.build:gradle version to 2.3.3.
then you need check gradle/wrapper/gradle-wrapper.properties distributionUrl gradle version
google Android Plugin for Gradle Release Notes
on the other hand
using newer plugin version might require to update Android Studio
thanks #antek
I also encountered this error when updating to 'com.android.tools.build:gradle:3.0.0'
To fix it, I had to add the google() repo to both the buildscript and module repositories. The documentation here only mentions adding to to the buildscript.
Project-level build.gradle
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
App-level build.gradle
repositories {
...
// Documentation doesn't specify this, but it must be added here
google()
}
gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
had similar problem, issue was different versions of included library. to find out what causes problem run build command with stacktrace
./gradlew build --stacktrace
In my case, i got wifi problem. make sure you have valid internet connection
In my case I solved this error only by Invalidating caches.
File > Invalidate caches / Restart
This is neither an exact answer to the question nor a silver bullet.
However, if nothing works for you e.g. Invalidate cache & restart, Checking build dependency, Disabling Instant Run (I never advise that) etc.
Add command-line option --stacktrace in Setting > Build, Execution, Deployment > Compiler
Now build/assemble gradle once again. You will have detailed information about the cause. e.g. in my case:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException:
Could not find com.squareup.okhttp3:logging-interceptor:3.9.1Net.
I have misspelled the dependency name in module level gradle file. Hope that help
The problem is probably you're using a Gradle version rather than 3.
go to gradle/wrapper/gradle-wrapper.properties and change the last line to this:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
For those of you working on a team:
I pulled down some changes that included updating the build tools version, but I had not downloaded that new version of the build tools on my machine. Downloading the new version fixed this issue for me
For me, this issue arose due to an incompatible combination of plugin and gradle.
I added these to the code to have it working:
Main build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
Main gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Usually it depends on Instant run or Gradle, but I tried both variants and nothing helped me. Then I looked through idea.log and saw this error
Caused by: java.lang.RuntimeException: A conflict was found between the
following modules:
- com.android.support:support-core-utils:25.3.1
- com.android.support:support-core-utils:27.0.1
I really don't know why this error is not shown in Gradle Console or Event Log tab. Then I fixed it by adding some code to the end of android{} block.
configurations.all {
resolutionStrategy {
failOnVersionConflict()
eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'support-core-utils') {
details.useVersion '25.3.1'//Or you can use 27.0.1 if it does not conflict with your other dependencies
}
}
}
I had this issue because I was using Charles proxy on my computer and the SSL was enabled for all hosts. And since AS didn't trust my proxy, the network request failed.
So I had to disable SSL for all hosts and restart my Android Studio.
In my case I have changed version of Kotlin plugin in gradle file related to module but hadn't change it in root gradle file.
It is interesting but as for me help this:
File -> Setting -> Gradle -> disable offline work
I have met the similar problem.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0-milestone-1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
The key is you need to get a way to solve this kind of problems,not to
solve this problem.
According to the log above,the most important information is:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
Most of the building problems of Gradle will be solved because when you use the specific Gradle build command,you can get more detailed and useful information that are clear.
*clean project
./gradlew clean
*build project
./gradlew build
*build for debug package
./gradlew assembleDebug or ./gradlew aD
*build for release package
./gradlew assembleRelease or ./gradlew aR
*build for release package and install
./gradlew installRelease or ./gradlew iR Release
*build for debug package and install
./gradlew installDebug or ./gradlew iD Debug
*uninstall release package
./gradlew uninstallRelease or ./gradlew uR
*uninstall debug package
./gradlew uninstallDebug or ./gradlew uD
*all the above command + "--info" or "--debug" or "--scan" or "--stacktrace" can get more detail information.
And then I found the problem is related with the version of Gradle,when I have changed Gradle from 5.0 to 4.1,and then it's OK.
For me I had to specifically stop the gradlew and clear caches and this fixed my issues:
./gradlew --stop
// Delete all cache files in your project. With git: `git -xfd clean`
// Delete global cache dir. On Mac it is located in `~/.gradle/caches
Found here:
https://github.com/realm/realm-java/issues/5650#issuecomment-355011135
I've resolved this issue by cleaning all the Gradle cache, stoping the Gradle Daemon process, and created a new build successfully using the following command. Make sure your current directory is android.
rm -rf ~/.gradle/caches && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease
I'm using React Native. So I've added following in my scripts in package.json,
"build-android": "rm -rf ~/.gradle/caches && cd android && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease && cd ..",
Changing the below line in your gradle.build helps.
classpath 'com.android.tools.build:gradle:4.2.2'
With the new google support gradle plugin (com.google.gms.google-services) this can be caused by some dependency version problems with your com.google.android.gms.* modules.
You can probably see the root cause by running the build command with the --stacktrace parameter. i.e.:
./gradlew :app:dependencies --stacktrace
which might output the cause of the problem:
Caused by: org.gradle.api.GradleException:
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2],
[16.0.0,16.0.0]], but resolves to 16.0.0. Disable the plugin and check
your dependencies tree using ./gradlew :app:dependencies.
at com.google.gms.googleservices.GoogleServicesPlugin$1$_afterResolve_closure1.doCall(GoogleServicesPlugin.groovy:328)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
Just Change the Distribution url at gradle-wrapper.properties
Place it : https://services.gradle.org/distributions/gradle-4.10.1-all.zip
I ignored using JDK13 with Android Studio, So I selected below settings and it was solved:
Step 1. (File > Other Settings > Default Project Structure > SDK Location > JDK Location)
Embedded JDK
Step 2. (File > Project Structure > Project)
gradle plugin 3.6.3
gradle 5.6.4
I had buildToolsVersion "27.0.1", upgrading it to 27.0.2 fixed the issue.
Also, my android support deps were at version 27.0.2 so they were not aligned to the buildToolsVersion
The only thing that helped me was to use the system gradle instead of Android Studio's built-in:
SETTINGS -> Build, Execution, Deployment -> Gradle
Select Use local gradle distribution. To find the path, you can do which gradle where the which program is supported. It might be /usr/bin/gradle.
See also Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler for another possible cause.
SETTINGS -> Build, Execution, Deployment -> Gradle -> unselect Offline work
Then sync project, you are good to go.
If not working , then File > Invalidate caches / Restart - > Invalidate and Restart.
In my case, I was missing the target SDK platform installed. I remember this error was straightforward and prompted you to install it automatically. Worth checking that as well.
First Step:File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.
Second step: Press Invalidate/Restart.
done.... Enjoy.
In my case, I had to do -
File -> Sync Project with Gradle Files
In my case I had to update all the Firebase libraries to the latest versions.
I think u have to change compile by implementation first, then maybe the problem is your android version, it is not compatible with your code, so update it.
And Good luck
I have recently updated android studio to the latest version,but then comes the problem.
Gradle 'MyApplication' project refresh failed.
Error:Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
Found this in StackOverflow
However trying everything nothing works - cannot create new project of import anything at the moment.Please kindly advice.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.sclick.myapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
task assemble{}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
**Top Level Gradle.build**
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
gradle-wrapper.properties
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
I had same issue. I have tried many things but nothing worked Until I try following:
Close Android Studio
Delete any directory matching gradle-[version]-all within C:\Users\<username>\.gradle\wrapper\dists\. If you encounter a "File in use" error (or similar), terminate any running Java executables.
Open Android Studio as Administrator.
Try to sync project files.
If the above does not work, try restarting your computer and/or delete the project's .gradle directory.
Open the problem project and trigger a Gradle sync.
I had a similar issue, when I upgraded to the latest version of Android Studio 1.3.2. What seemed to work for me was removing the .gradle folder from my project directory:
rm -rf ~/project/.gradle
I had same issue when first start Android Studio in Window 10, with java jdk 1.8.0_66. The solution that worked is:
Step 1: Close Android Studio
Step 2: Delete Folder C:\Users\Anna\.gradle
(Anna is my username)
Step 3: Open Android Studio as Administrator
Step 4: If you are currently in an opened project, close current project by select File > Close Project.
Step 5: Now you seeing this Quick Start GUI:
Select Open an existing Android Studio project, navigate to your project folder and select it.
Wait for gradle to build again (it would download all the dependency in your build.gradle for every module in your project)
If it has not worked till now, you could restart your computer. Do step 1 again.
This happens sometime when I changed Android Studio version or recently upgrade Window. Hope that helps !
I forced to use a proxy and also forced to add proxy setting on gradle.properties as these:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
And also forced to close and open studio64.exe as administrator .
Now its all seems greate
Event log says
8:21:39 AM Platform and Plugin Updates: The following components are ready to update: Android Support Repository, Google Repository, Intel x86 Emulator Accelerator (HAXM installer), Android SDK Platform-Tools 24, Google APIs Intel x86 Atom System Image, Android SDK Tools 25.1.7
8:21:40 AM Gradle sync started
8:22:03 AM Gradle sync completed
8:22:04 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar]
8:22:25 AM Gradle build finished in 21s 607ms
I'm using android studio 2.1.2 downloaded as exe setup file. it has its Gradle ( I also forced to use custom install to address the Gradle )
Go on Project->Settings->Compiler(Gradle-based android project), find the text field "VM option" and put there:
-Xmx512m -XX:MaxPermSize=512m
This shouls solve the issue in any case the error shown in the gradle message window is "Could not reserve enough space for object heap"
Hope this helps
You can download the gradle you want from Gradle Service by reading the gradle-wrapper.properties.Download it ,unpack it where you like and then change your grandle configuration use local not the recommended.
I had the same problem and I Just Invalidate caches/restart
Try updating gradle dependency to 2.4. For that you need to go to
File -> Project Structure -> Project -> Gradle version.
There you need to change from 2.2.1 to 2.4. Wait for new gradle version to be downloaded.
And you are ready to go.
I have run into a similar problem on Mac.
Looking at the log under Help -> Show logs in Finder I found the following entry.
You have JVM property "https.proxyHost" set to "127.0.0.1".This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP ProxyThis JVM property is old and its usage is not recommended by Oracle.(Note: It could have been assigned by some code dynamically.)
and it turned out I had Charles as a network proxy running. Shutting down Charles solved the problem.
I'm trying to create a simple android project with gradle. I work in a computer with Debian GNU/Linux 7 'wheezy'.
I followed the recomendations in Gradle Plugin User Guide - Android Tools Project Site, but it casts an error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/alex/Proyectos/MyLogin/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating root project 'MyLogin'.
> Could not create plugin of type 'AppPlugin'.
* 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: 4.817 secs
I followed the specifications:
Gradle 1.9
Plugin 0.7
SDK 17+ (actually 19)
I also started a project anew, and the results I showed were issued by the command gradle tasks as shown in the documentation.
I also tried gradle 1.10, but the result is the same.
Even this question was not usefull, since it solved with 'upgrading' to gradle 1.6 (I understand that plugin 0.7 requires at least gradle 1.9).
I tried this after failing with the same error in android-studio and IntelliJ Idea.
EDIT: I also tried with new projects in both IDEs, and got the same issue. But what most surprises me is that both IDEs use gradle 1.8 in their wrapped form. I tried to cinfigure both of them to use my local gradle install, but still the same issue.
What am I doing wrong? Is it a bug? How can I avoid the problem?
Please, help me.
EDIT: Here is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 14
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
sourceCompatibility = 1.6
version = '0.1'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile project(':core')
}
Google made a mistake with version 0.7.2 of the Gradle plugin:
Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.
Release 0.7.3 re-enables Java6 support. Declaring Gradle 0.7.3 in my build files does indeed resolve this for me.
No one is perfect :)
http://tools.android.com/tech-docs/new-build-system
Use Gradle 1.9 instead of Gradle 1.10. There is an issue with 1.10 : https://code.google.com/p/android/issues/detail?id=63822
Also answered here:
Can't find org.gradle.api.artifacts.result.ResolvedModuleVersionResult when apply Android plugin in Gradle
I got it working using Gradle 1.10 with the Gradle plugin 0.8.0.
// /build.gradle
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
...
# /gradle/wrapper/gradle-wrapper.properties.
#Sat Feb 01 20:41:29 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
If you're using the command line to create the project like so:
android create project -g -v 1.2.2 --target 1 --name rtest --path rtest --activity MainActivity --package com.mydomain.rtest
The project is created to use version 1.2.2 of the android-gradle-plugin, but the project is initialised with gradle 1.12, which isn't compatible.
To fix it, do the following:
Open rtest/gradle/wrapper/gradle-wrapper.properties and set distributionUrl to the release you want; for example: http\://services.gradle.org/distributions/gradle-2.2.1-all.zip (don't forget to escape the colon - yes, that makes me smile too);
Open build.gradle and change runProguard false to minifyEnabled false;
./gradlew clean && ./gradlew assembleDebug
I also remove the hidden .gradle folder, but I'm not sure if it's necessary
And it all works again.
For those who are using 2.1 version of studio, replace classpath 'com.android.tools.build:gradle:2.1.0-rc1' with classpath 'com.android.tools.build:gradle:2.1.0'. This solved my problem.
If you are attempting to update your Gradle 1.9 project to Gradle 1.10 using
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
and command ./gradlew wrapper you will get the same error as above.
Solution is to install Gradle 1.10 onto your machine and upgrade your project not using the wrapper
gradle wrapper
You can also get this error if you update your system gradle and forget to update the Android Studio gradle home.
I got this today when running gradle assembleRelease. I had installed the Ubuntu default of gradle-1.4. This didn't work, so I tried the latest gradle-1.12 and got the same issue.
Downloading and using gradle-1.10 (and matching my gradle-wrapper.properties file to that version) resolved the issue.
This is with Android Studio 0.5.8.
Go to dependencies and just change the dependencies classpath to
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
Rest Gradle will take care. Happy coding :)
Ok i guess android studio has answer for this to get this bug out using GUI,
I had this error like this...
after updating the plugins i was facing another issues while building,
so changes the gradle setting to default as shown in the image,
After this build was successful.