Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create an Android project from the command line

I'm trying to create an Android project from the command line.

I tried what it is on the following link:

How to create android project with gradle from command line?

android create project \
    --gradle \
    --gradle-version 0.10 \
    --activity Main \
    --package com.example.app \
    --target android-19 \
    --path AppWithGradleTemplate

but I get:

**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invalid or unsupported command "create project"

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk

So, I think that's not an option.

On the deprecation message they say:

For command-line tools, use tools\bin\sdkmanager.bat

but I don't find the way to achieve this.

I want to specify the following parameters on the command line (among others):

- package
- activity name
- target
- etc.

Is gradle an alternative?

like image 895
Angel Avatar asked Feb 27 '26 19:02

Angel


2 Answers

Unfortunately I haven't found any satisfying way to do this.

The closest option I've found is to use gradle init, which creates a new gradle project following various templates: https://docs.gradle.org/current/userguide/build_init_plugin.html

Unfortunately, it doesn't include a template for Android. There is also no way to extend it by adding new templates, although it is a feature the gradle team are apparently discussing: https://github.com/gradle/gradle/issues/1686

This means you'll have to make do with the Kotlin template, and then manually add the Android framework stuff yourself.

If you don't want to have to maually add Android stuff, you could also go the painful route and create a new template by just making a new tool based on the gradle init source code, which is available here: https://github.com/gradle/gradle/tree/master/subprojects/build-init

like image 94
Luke Avatar answered Mar 02 '26 14:03

Luke


There is no such command in the Android SDK anymore, AFAIK.

like image 42
CommonsWare Avatar answered Mar 02 '26 13:03

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!