I'm new to Gradle and Java development and I'm having a hard time using a Gradle project which requires an old version of Gradle.
Basically, the problem is that every gradle command I run ends up with the same error:
FAILURE: Build failed with an exception.
* Where:
Build file '/var/code/doron/reverb/libpulse-android/build.gradle' line: 10
* What went wrong:
A problem occurred evaluating project ':libpulse-android'.
> Failed to apply plugin [id 'android-library']
> Gradle version 1.10 is required. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in /var/code/doron/reverb/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-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
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/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 0s
From what I understood, the recommended way to work with this kind of project is to install and use the gradle wrapper - Use the ./gradlew command instead of the system's gradle. I have searched the internet and reached this web page: https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:adding_wrapper Which basically says I should run:
gradle wrapper --gradle-version 1.10
But that ends in the same errors as above!
When searching for an answer, I have encountered this question: Getting error "Gradle version 1.10 is required. Current version is 1.12." when executing "gradle wrapper"? Which have failed to solve my problem. It seems the answers for that question only try to explain why the problem happens and not how to solve it.
Do you see why the problem is absurdly recursive? I can't install a needed version of Gradle in a wrapper because the build fails and the build fails because I don't use a specific version of gradle and I don't use the wrapper which I can't install.
If you don't yet have the Wrapper in your project: what you can do is to create a new temporary Gradle project, configure the wrapper in this project to match your needed gradle version, and then copy the wrapper related files into your initial project. If you already have a wrapper you can simply configure it by changing distribution url in ./gradle/wrapper/gradle.properties:
In details
1) create new empty project
mkdir tmp-project
cd tmp-project
gradle init
2) change wrapper version
gradle wrapper --gradle-version 1.10
3) check version (this will download the distribution)
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-1.10-bin.zip
......................................
------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
4) copy the wrapper related resources to your project:
./gradle/ directory
./gradlew script
./gradlew.bat script
open gradle-wrapper.properties in GradleScripts file change distributionUrl like below
#Thu Apr 12 11:14:54 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
don't forget to clean and rebuild project
Related
I have created a Flutter project in Android Studio (Bumblebee | 2021.1.1 Patch 3). When I open the android folder in a seperate window, when the gradle syncing is being executed, it fails with the message Gradle project sync failed. Basic functionality(e.g. editing,debugging) will not work properly. I ran ./gradlew --warning-mode all in the command line and it's output is
Configure project :app
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:863)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:864)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
> Configure project :system_alert_window
WARNING: The option setting 'android.enableR8=true' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :help
Welcome to Gradle 6.7.
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>
For troubleshooting, visit https://help.gradle.org
The last warning is due to system_alert_window (flutter)plugin that I am using. But these deprecation warnings are causing issues in Android Studio editor so that I am unable to use code completion feature. I don't know why is this happening, since these are only warning messages.
My gradle version is 6.7 and android-gradle version is 4.1.0.
Can anyone please help?
TRY this steps-
Step 1:
Open the gradle.properties file same like given Image-
https://i.stack.imgur.com/S2Y0a.png
Step 2:
Disable android.enableR8=true by adding a # in front:
#android.enableR8=true
Alternatively, you can swap out the R8 for D8, The build system changed to using D8 instead of R8.
android.enableD8=true
After i have updated android studio to 3.4.2 and gradle,
when i run this line
gradlew publishApkappNameRelease
im getting this error :
* What went wrong: Some problems were found with the configuration of task ':app:generateappNameReleasePlayResources'.
> File 'E:\Projects\packagename\app\src\main\play' specified for property '$1' does not exist.
> File 'E:\Projects\packagename\app\src\appName\play' specified for property '$2' does not exist.
> File 'E:\Projects\packagename\app\src\release\play' specified for property '$3' does not exist.
> File 'E:\Projects\packagename\app\src\appNameRelease\play' specified for property '$4' does not exist.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 47s 56 actionable tasks: 55 executed, 1 from cache
note: this line is used to auto publish apk using
apply plugin: 'com.github.triplet.play'
classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
same when i run this command line gradlew --recompile-scripts i get error
Unknown command-line option '--recompile-scripts'
These commands were running fine before the updates.
UPDATE:
when i try to update the triplet.play to any of t hose versions (2.2.1 - 2.2.0 - 2.1.1 - 2.1.0 - 2.0.0 - 2.0.0-rc2) i get this error
Could not find com.github.triplet.gradle:play-publisher:2.2.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.pom
- https://dl.google.com/dl/android/maven2/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.jar
- https://jcenter.bintray.com/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.pom
- https://jcenter.bintray.com/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.jar
- https://repo.maven.apache.org/maven2/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.pom
- https://repo.maven.apache.org/maven2/com/github/triplet/gradle/play-publisher/2.2.1/play-publisher-2.2.1.jar
Required by:
project :
Apparently this can be fixed by upgrading the version of the play-publisher plugin from 1.1.5 to 2.1.1 as per the GitHub issue here: https://github.com/Triple-T/gradle-play-publisher/issues/532
However, it seems that the newer versions of the plugin aren't available on all artifact repositories. I found it here which has clear steps of doing it: https://plugins.gradle.org/plugin/com.github.triplet.play
Lastly it is advised that you check their GitHub page again to make sure that the config you currently have is still compatible: https://github.com/Triple-T/gradle-play-publisher
With regards to gradlew --recompile-scripts, this has been deprecated and removed in the new version since most of the times the gradle daemon is running and ignores this option. More info here: https://github.com/gradle/gradle/issues/1425
First, add a new repo to your repositories on build.gradle (Project)
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
Now , upgrade your classpath.
classpath 'com.github.triplet.gradle:play-publisher:2.1.1'
I have a Cordova/Phonegap application, every time when I rebuild the application using cordova build android it gives me below error.
ANDROID_HOME=/Users/name/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/name/Desktop/Ponet/zoomber/platforms/android/build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'android']
> Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in /Users/name/Desktop/Ponet/zoomber/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
* 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: 1.256 secs
Error: Error code 1 for command: /Users/name/Desktop/Ponet/zoomber/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/name/Desktop/Ponet/zoomber/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
Recently I have updated my Android Studio 1.5 to 2.1 and imported previous project setting. Problem can be solved if I removed my android platform and add it again and rebuild the application. But this is very time consuming to do. Please provide any suggestions or solutions?
I tried below answers: (not Cordova specific)
Gradle version 2.10 is required. Current version is 2.8 Error
Thank you in-advance!
Edit the /Users/name/Desktop/Ponet/zoomber/gradle/wrapper/gradle-wrapper.properties file and set the distributionUrl property to
https\://services.gradle.org/distributions/gradle-2.14-all.zip
(current version at time of writing)
I'm using Eclipse Luna to develop my Android app. I don't have any idea why the error message keep showing again and again. I got this error message after fill up dependencies in build.gradle and run gradle build in my terminal.
build.gradle
dependencies {
compile 'com.lorentzos.swipecards:library:1.0.8#aar'
}
Error message
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/MNurdin/Documents/Github/Swipecards/example/src/main/build.gradle' line: 2
* What went wrong:
A problem occurred evaluating root project 'main'.
> Could not find method compile() for arguments [com.lorentzos.swipecards:library:X.X.X#aar] on root project 'main'.
* 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.34 secs
Project: https://github.com/datomnurdin/Swipecards
change to this:
compile 'com.lorentzos.swipecards:library:1.0.8'
I encountered the error when I tried using gradle 2.6 to build a project that was built using gradle 2.3. Make sure the versions are the same.
The compile task is defined by the java plugin. However, as you do not include it in your root project it does not exist there so gradle does not know how to handle it.
In order to resolve it you can either:
Apply the java plugin to your root project. The downside of this approach would be that this plugin will be included automatically in all your sub project that in somecases may be undesired, and also by default there will be an empty jar created for this project.
Define a dummy empty compile task yourself so gradle will be happy.
compile is a dependency configuration that comes from the Java Plugin.
The Android Gradle plugin applies the Java plugin under the covers. I do not see the Android plugin applied in your Gradle script. I think you may be missing a module-level build configuration that applies the Android Gradle plugin which would add dependencies.compile(...) to the DSL.
I'm following an article from http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/ and downloaded the sample git hub project https://github.com/android10/Android-CleanArchitecture.
The project has been build using gradle, since my previous projects was build using the default builder of android, i found this hard building the project.
I already set up the environment of the gradle. but when I tried to build the project using gradle build on the root folder i get this error.(NOTE: Im using Intellij as my IDE)
I first performed gradle build in the root folder but received this error:
* Where:
Build file '/Users/magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/data/build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':data'.
Failed to apply plugin [id 'android-library']
Gradle version 1.10 is required. Current version is 2.1. If using the gradle wrapper, try editing the distributionUrl in /Users/magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
So, i went to folder gradle and change the gradle-wrapper.properties to gradle-1.10-all.zip and perfomed ./gradlew build but got this error:
FAILURE: Build failed with an exception.
Where:
Build file '/Users/Magic/Desktop/android/myProjects/TestingProjects/Android Clean Architecture/Android-CleanArchitecture-master/data/build.gradle' line: 9
What went wrong:
A problem occurred evaluating project ':data'.
Could not find method applicationId() for arguments [com.fernandocejas.android10.sample.data] on ProductFlavorDsl_Decorated{name=main, minSdkVersion=-1, targetSdkVersion=-1, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=-1, versionName=null, packageName=null, testPackageName=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
and its pointing to line 9
defaultConfig {
applicationId "com.fernandocejas.android10.sample.data" //line 9
minSdkVersion 15
targetSdkVersion 19
}
I would really appreciate your inputs with this.
Thanks.
I just downloaded that project, imported it into Intellij 13.1 (using the gradle wrapper), and it worked out of the box. You have made changes to the build.gradle files that have broken it. It is hard to say what the issue is without all your gradle files posted here. One indication that the gradle files have been modified is that one of the errors you gave was:
Failed to apply plugin [id 'android-library']
But the example does not apply this plugin, it applies the correct one, i.e.:
apply plugin: 'com.android.library'
Try getting that project again and don't change the gradle build files. Also make sure you are importing with the gradle wrapper, and not your local distribution of gradle.
I hope this helps!