How to create android project with gradle
from command line (without any IDE)?
Before it was with android
util like below
android create project --target 1 --name MyAndroidApp --path ./MyAndroidAppProject --activity MyAndroidAppActivity --package com.example.myandroid
android create project
was removed in SDK tools 26.0.1See https://askubuntu.com/questions/906942/android-update-project-path-target-android-25-on-ubuntu-16-04 for more details
Trying to use it fails with:
Workaround: Android Studio template + copy helper script
The best workaround I have is to:
The following helper script allows you to do:
to get a new app
NewAppName
from an existingAppTemplateProject
created with Android studio:GitHub upstream: https://github.com/cirosantilli/android-cheat/blob/0e6b7462705179658b48d0e2e27f0dbce308393c/gradle/template
Yes it is not perfect. CLI support appears secondary to Google :-(
Similar to How to create Java gradle project suggest to create Android project with
android create project
than addbuild.gradle
template for classic Android project gh.c/N/n-1/b/m/o.n.e.e.g/docs/android/build.gradle. (That would allow to develop in any IDE, as old structure is more widely adopted)Of course there will be some
gradle init
options orandroid create
(from SDK) in the future.UPDATE:
Android SDK 19 has
android
CLI-g
option that allows to use gradle template. You might also need to specify android gradle plugin version with CLI-v
option, check android gradle plugin compatibility table. Example command to create the project that uses android gradle plugin (v 0.10) to add gradle support.or for buildTools 19.1+, use a newer version of the Gradle Android plugin via
--gradle-version
:check
android create project -h
for helpHowever Android Studio 0.6.1 failed to open it correctly (no sources shown), because it took first project folder (that is
gradle
) as module folder -> you need to Import, not just open.In Eclipse it was with a trick of regarding
src
folder as root of the project..classpath
isAnd
build.gradle
http://marketplace.eclipse.org/content/gradle
read at http://www.nodeclipse.org/projects/gradle/