7

I am trying to create android project with gradle from command line using this command:

  android create project \
    --target android-23 \
    --name HelloWorld \
    --path HelloWorld/ \
    --activity MainActivity \
    --package com.example.helloworld \
    --gradle \
    --gradle-version 1.3.0

Project structure was successfully generated but when I try to run gradlew assembleDebug I get:

A problem occurred evaluating root project 'HelloWorld'.
> Could not create plugin of type 'AppPlugin'.

I was traversing google for half of day and finally I found that usage of gradle in android create project is (probably) deprecated:

https://code.google.com/p/android/issues/detail?id=160032

Are there any supported methods (that are clean, no hacks) to achieve the goal (in command line)?

4
  • 1
    An Android project is just a directory of files. Create a template project (e.g., using Android Studio). Write a script that copies the template and modifies the variable bits (e.g., application ID, package name). I am not aware of such an existing script, but it shouldn't be all that hard to craft. Commented Mar 5, 2016 at 13:34
  • 2
    @CommonsWare: thx for answer; I created such script already but I wanted to know if there is any existing official tool that will give me guaranty that project structure will be fine for any new version of android gradle plugin, android sdk etc. Commented Mar 5, 2016 at 18:15
  • 1
    Official tool? None that I am aware of. Google's focus is Android Studio for app development and command-line only for CI servers and other build scenarios. I would be somewhat surprised if Google put much engineering effort into command-line tools for project creation. Commented Mar 5, 2016 at 18:17
  • 1
    That's a pitty. But from other hand, there is potential for building some good open source. It seems that there are some people who was looking the same. Thanks for answer. Commented Mar 6, 2016 at 17:58

1 Answer 1

2

As instructed here:

http://eqdn.tech/android-development-on-the-command-line/

You can still use "android create project", but will need to adjust the results manually a little bit afterwards. Essentially changing in gradle/wrapper/gradle-wrapper.properties this:

distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip

To this:

distributionUrl=http://services.gradle.org/distributions/gradle-2.2.1-all.zip

And changing "runProguard false" to "minifyEnabled true" in build.gradle.

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

1 Comment

Since there exists no better solution, I accept this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.