Gradle task assembleRelease not found in CI build, works with Android Studio

白昼怎懂夜的黑 提交于 2020-01-25 07:49:07

问题


I am trying to use gitlab/fastlane to build my project. When i execute the scripts in the default project they work correctly, but when the runner checks out the project the build fails with the message "Task 'assembleRelease' not found in root project 'projectname'".

When i open the CI project location in Android Studio I have to execute "sync project with gradle files" before build is available. After I have done this i can execute ./gradlew assembleRelease (and the fastlane script also works correctly)

The console output shows that several files/directories are removed when the repository is checked out:

Removing .gradle/
Removing .idea/
Removing app/app.iml
Removing app/build/
Removing build/
Removing local.properties
Removing project.iml

I can't seem to find what exactly Android Studio does when I select "Sync Project with Gradle Files" and how i reproduce that with my build script.


回答1:


I had the same problem. The reason was that the ANDROID_HOME environment variable was not set and the local.properties file did not have an sdk.path set.

You could set it via Jenkinsfile into the local.properties file:

sh 'echo "sdk.dir=/<your_path_to_Android_SDK>" > ./local.properties' in my case:
sh 'echo "sdk.dir=/home/jenkins/Android/Sdk" > ./local.properties'

Instead of writing it into the Jenkinsfile you could also create a custom fastlane lane which calls the the above mentioned shell command before you execute ./gradlew assembleRelease



来源:https://stackoverflow.com/questions/58080650/gradle-task-assemblerelease-not-found-in-ci-build-works-with-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!