使用 gradle 从命令行创建 android 项目已弃用?

create android project with gradle from command line deprecated?

我正在尝试使用以下命令从命令行使用 gradle 创建 android 项目:

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

项目结构已成功生成,但是当我尝试 运行 gradlew assembleDebug 我得到:

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

我遍历了 google 半天,最后我发现 gradle 在 android 创建项目中的用法(可能)已弃用:

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

是否有任何受支持的方法(干净、没有 hack)来实现目标(在命令行中)?

按照此处的说明:

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

您仍然可以使用 "android create project",但之后需要稍微手动调整结果。 gradle/wrapper/gradle-wrapper.properties 中的本质更改为:

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

为此:

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

并在 build.gradle 中将 "runProguard false" 更改为 "minifyEnabled true"。