tirenweb
tirenweb

Reputation: 31749

Android: run an app from the command line for the first time

In the docs, I have found these lines below when trying to run an app.

Run the app from a command line
-------------------------------

Open a command-line and navigate to the root of your project directory. Use Gradle to build your project in debug mode, invoke the assembleDebug build task using the Gradle wrapper script (gradlew assembleRelease).

This creates your debug .apk file inside the module build/ directory, named MyFirstApp-debug.apk.

On Windows platforms, type this command:

> gradlew.bat assembleDebug

On Mac OS and Linux platforms, type these commands:

$ chmod +x gradlew
$ ./gradlew assembleDebug

So I have installed Gradle, and supposing that gradle wrapper is the same as gradlew, I have done the same steps, but when I try to run:

/MyFirstApp$ gradle wrapper assembleDebug

FAILURE: Could not determine which tasks to execute.

  • What went wrong: Task 'wrapper' not found in root project 'MyFirstApp'.

  • Try: Run gradle tasks to get a list of available tasks.

BUILD FAILED

Total time: 1.946 secs

This is the content of my MyFirstApp directory:

AndroidManifest.xml  bin        **gradlew**  local.properties      project.properties  src
ant.properties       build.xml  libs     proguard-project.txt  res

As you can see I have also gradlew command since I have copied from /home/me/Downloads/android-sdk-linux/tools/templates/gradle/wrapper/gradlew. But when I try to run ./gradlew assembleDebug I get this:

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Upvotes: 1

Views: 1444

Answers (1)

Larry Schiefer
Larry Schiefer

Reputation: 15775

The command gradle wrapper actually sets up a directory (project) for building with gradle using the wrapper. It fetches the wrapper script/executable and pulls a version of gradle locally into the directory (ok, a subdirectory.) It's not the same as calling gradlew as gradlew is the wrapper itself.

Did you create your Android project using Android Studio? It will have setup the wrapper for you and pre-populated the build.gradle, settings.gradle and other necessary files.

Upvotes: 0

Related Questions