gpt4 book ai didi

android - 在 OSX : Task 'assembleDebug' not found in root project 上的命令行上构建 Android 项目

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:52 36 4
gpt4 key购买 nike

我正在尝试使用以下方法在 OSX (Mavericks 10.9.5) 命令行上构建 Android 项目:http://developer.android.com/tools/building/building-cmdline.html .

本操作指南介绍了如何使用 assembleDebug/assembleRelease 构建 Android 项目。

不幸的是,gradle 不会创建 assembleDebugassembleRelease 目标。

执行 ./gradlew assembleDebug 返回:

FAILURE: Build failed with an exception.

* What went wrong:
Task 'assembleDebug' not found in root project 'test'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.826 secs

步骤:

android 创建项目

测试项目已使用 android create project --path 创建。 --name "DummyAPK"--target android-21 --package com.dummyapk.dummyapk --activity DummyActivity

哪个返回了

Created directory /Users/user/Documents/test/src/com/dummyapk/dummyapk
Added file ./src/com/dummyapk/dummyapk/DummyActivity.java
Created directory /Users/user/Documents/test/res
Created directory /Users/user/Documents/test/bin
Created directory /Users/user/Documents/test/libs
Created directory /Users/user/Documents/test/res/values
Added file ./res/values/strings.xml
Created directory /Users/user/Documents/test/res/layout
Added file ./res/layout/main.xml
Created directory /Users/user/Documents/test/res/drawable-xhdpi
Created directory /Users/user/Documents/test/res/drawable-hdpi
Created directory /Users/user/Documents/test/res/drawable-mdpi
Created directory /Users/user/Documents/test/res/drawable-ldpi
Added file ./AndroidManifest.xml
Added file ./build.xml
Added file ./proguard-project.txt

渐变初始化

之后我执行了 gradle init,它返回了

:wrapper
:init
BUILD SUCCESSFUL

gradlew 任务

gradlew tasks查询可用任务返回(是不是漏了什么?)

:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
components - Displays the components produced by root project 'test'. [incubating]
dependencies - Displays all dependencies declared in root project 'test'.
dependencyInsight - Displays the insight into a specific dependency in root project 'test'.
help - Displays a help message.
projects - Displays the sub-projects of root project 'test'.
properties - Displays the properties of root project 'test'.
tasks - Displays the tasks runnable from root project 'test'.

To see all tasks and more detail, run with --all.

BUILD SUCCESSFUL

Total time: 3.474 secs

我的Java版本是

java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

..和 Gradle 版本(通过 brew 安装)是

------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------

Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_60 (Oracle Corporation 24.60-b09)
OS: Mac OS X 10.9.5 x86_64

我缺少什么能够在命令行上构建 Android 项目?

最佳答案

android create project 不会创建 gradle 友好结构。它创建了一个 ant 友好的结构。根据您的 Intent ,您有两种选择。

  1. 使用 ant 构建您的项目(Android 团队目前不支持)
  2. 使用 Android Studio 生成一个 gradle 友好的项目结构。

num 2 是 Android 团队推荐的方法。就像 dl'ing Android Studio 一样简单并创建一个新项目。从那里您应该能够创建一个可以使用 ./gradlew build

构建的新项目

关于android - 在 OSX : Task 'assembleDebug' not found in root project 上的命令行上构建 Android 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27490616/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com