9

I am trying to figure out, how to build apk-s using shell. I came over gradlew script, that should do the work for me. Yet, I miss this file in my directory, I have only the windows gradlew.bat file, that doesn't fit my purposes. I read that i have to add in my build.gradle file.

task wrapper(type: Wrapper) { gradleVersion = '2.0' } 

Yet, i still don't know if this task should be placed to my project build file or to my module build file(tried out both - didn't help). Any tipps are appreciated.

1 Answer 1

13

Simply run this via command line:

gradle wrapper 

Also, Gradle 2.4 is the latest release and 2.5 should be out soon. So you might want to do:

task wrapper(type: Wrapper) { gradleVersion = '2.4' } 

or

gradle wrapper --gradle-version 2.4 

Please read the docs here: https://docs.gradle.org/current/userguide/gradle_wrapper.html

Sign up to request clarification or add additional context in comments.

6 Comments

executing "gradle wrapper" helped, but for upcoming troubles, can you tell, where should i place this "task wrapper"? in which file?
You can just simply put it in the "top" build.gradle.
It is not so simple here. Having omitted the definition of gradle version in the Android Studio / project structure, i.e. left as blank, this exception is produced upon the suggested solution. Why? gradlew Exception in thread "main" java.lang.RuntimeException: Could not load wrapper properties from 'C:\...\gradle\wrapper\gradle-wrapper.properties'. at org.gradle.wrapper.WrapperExecutor.<init>(WrapperExecutor.java:65)
@carl Generate like I did in my answer, then hook it up with the IDE.
Thanks, @Jared Burrows, the problem with this is a chicken and egg problem. The gradle wrapper batch files are generated to avoid installing this or that version of gradle manually, but rather, let the build process decide gradle version, which then is downloaded if necessary. The problem is that you actually need a local gradle installation in order to generate the gradlew(.bat) files with your command: "Gradle wrapper". It was quite a timethief to find out about this, hopefully this comment will help others. Perhaps state that a gradle installation is mandatory? Given that, it is simple, yes
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.