我有一个android项目。它有2种口味,分别是GooglePlay和Cafebazzar。

使用Android Studio时,我看到assembleRelease和assembleCafeBazzar以及assembleGooglePlay。

android - 在 Jenkins 的任务gradle中找不到assembleRelease-LMLPHP

当我在 Jenkins 中使用 ./gradlew -q任务-所有时,在我的任务中看不到assembleRelease。
我看到组装。
我使用Jenkins构建项目。如何在Jenkins中看到assembleRelease?

    + ./gradlew -q tasks --all

------------------------------------------------------------
Tasks runnable from root project
------------------------------------------------------------

Android tasks
-------------
app:sourceSets - Prints out all the source sets defined in this project.
core:sourceSets - Prints out all the source sets defined in this project.
skeleton:sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
app:assemble - Assembles all variants of all applications and secondary packages.
core:assemble - Assembles all variants of all applications and secondary packages.
skeleton:assemble - Assembles all variants of all applications and secondary packages.
app:assembleAndroidTest - Assembles all the Test applications.
core:assembleAndroidTest - Assembles all the Test applications.
skeleton:assembleAndroidTest - Assembles all the Test applications.
app:build - Assembles and tests this project.
core:build - Assembles and tests this project.
skeleton:build - Assembles and tests this project.
app:buildDependents - Assembles and tests this project and all projects that depend on it.
core:buildDependents - Assembles and tests this project and all projects that depend on it.
skeleton:buildDependents - Assembles and tests this project and all projects that depend on it.
app:buildNeeded - Assembles and tests this project and all projects it depends on.
core:buildNeeded - Assembles and tests this project and all projects it depends on.
skeleton:buildNeeded - Assembles and tests this project and all projects it depends on.
app:clean - Deletes the build directory.
core:clean - Deletes the build directory.
skeleton:clean - Deletes the build directory.
app:cleanBuildCache - Deletes the build cache directory.
core:cleanBuildCache - Deletes the build cache directory.
skeleton:cleanBuildCache - Deletes the build cache directory.

最佳答案

当我 checkout 我的项目“assembleRelease”不能作为任务时,我遇到了同样的问题。
当我在Android Studio中打开项目并选择“与gradle同步”时,会有一些 Activity ,之后我可以从命令行执行“gradlew assembleRelease”。

我不知道“与gradle同步”到底是做什么的。似乎有一个命令曾经做过类似的事情,但似乎不再可用。

编辑:
似乎文件local.properties是通过运行“与gradle文件同步”创建的。我创建了一个示例来在googles issuetracker中重现该问题,似乎该文件使assembleRelease是否可用与众不同。

编辑2:
FaSTLane现在正在运行,我在安装过程中将local.properties文件复制到构建目录中。
根据我对类似问题Gradle task assembleRelease not found in CI build, works with Android Studio的评论,这是因为未设置ANDROID_HOME。

10-04 13:50