These are instructions for building an existing Android project using gradle.
If you want to create a new Android project using gradle, please proceed to Creating a new project
cd
into theAndroidProject
folder- create a file called
local.properties
- in the file, enter your local android sdk dir:
sdk.dir=/path/to/sdk/dir
cd
to the root folder- type
gradle androidPackage
to do a complete build (including tests) - type
gradle androidInstall
to install the application in a device or a running emulator - type
gradle tasks
to see a list of all gradle tasks
cd
to the root folder- type
gradle eclipse
- start Eclipse
- select File - Import - Existing Projects into Workspace
- select the root folder containing the AndroidProject and the AndroidProjectTest projects
- right click on the AndroidProject
- select Android Tools - Fix Project Properties
- in the project explorer, select the AndroidProjectTest project
- select Run - Run Configurations...
- select JUnit and click the yellow + button
- select Test Runner - JUnit 4
- go the the tab 'Arguments'
- select Working directory - Other
- select Workspace... - AndroidProject and click OK
- click Multiple launchers available - Select one...
- choose the Eclipse JUnit Launcher (NOT the Android JUnit Test Launcher)
These are instructions for using the gradle build files from this project in a new Android project.
-
Copy the following folder structure from this project:
- .gitignore
- build.gradle
- README.md
- settings.gradle
- AndroidProject
- AndroidProject/build.gradle
- AndroidProjectTest
- AndroidProjectTest/build.gradle
-
Create a new Android project in the AndroidProject folder. You can use Eclipse for this.
- Make sure the target folder for the new Eclipse project is the AndroidProject folder.
- Do NOT create an android Test Project.
-
Follow the steps in Setting the Android SDK dir as described above
-
Go to the root folder (containing README.md) and type
gradle :_AndroidProjectTest_:eclipse
-
In Eclipse: import the generated existing project into the workspace
-
Follow the steps in Setting up Eclipse test configuration as described above
- You can change the project names AndroidProject and AndroidProjectTest into XXX and _XXX_Test.
- It is possible to use AndroidProject/build.gradle without the test project.
- Make sure you do NOT check in files specified in .gitignore in version control. This will cause problems.