android - 从不推荐使用命令行的 gradle 创建 android 项目?

标签 android android-gradle-plugin android-sdk-tools

我正在尝试使用以下命令从命令行使用 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'.

我在谷歌上搜索了半天,最后我发现 gradle 在 android create project 中的用法(可能)已被弃用:

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

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

最佳答案

按照这里的说明:

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”。

关于android - 从不推荐使用命令行的 gradle 创建 android 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35814663/

相关文章:

java - 自动更改android中最新 ListView 项的背景颜色

java - 在 Activity 之间传递 Future 对象

android - 从 Android Studio 中的外部项目链接模块

android - Flutter Doctor 无法识别我的 ANDROID_SDK 环境变量

android - 如何将Android Gradle项目依赖项下载到自定义文件夹?

android - Ubuntu 12.04 中没有为 Kivy 设置 Android SDK 环境

android - CoreComponentFactory 未找到类 "android.support.v4.app.CoreComponentFactory"

java - 我无法登录或注册我的应用程序

android - 类名与路径不匹配?

android - Gradle使用本地存储的依赖项还是始终从Internet下载内容?