I am trying to setup Bamboo for my Gradle build system based Android Project.
I have done the following setup on Bamboo.I'm done with rest of all setup upto project repository path.
I want to run the following tasks using gradlew for android
clean assembleDebug LintDebug
For that I have created new task called Gradle Wrapper.
Below is the Gradle Wrapper Configuration
When I am executing gradle wrapper task, I am getting the following error.
Caused by: java.lang.IllegalStateException: Cannot find executable 'D:\AndroidDemo\gradle-2.10\bin\gradlew.bat'
Note :- Standalone Gradle is working fine on local machine with all the tasks(clean assembleDebug LintDebug)
Gradle_Home = D:\AndroidDemo\gradle-2.10\bin(Local machine)
Can anyone suggest a solution for the same?
I also had some initial difficulties to set up Bamboo to build an Android project using Gradle.
First of all, make sure that you have the Gradle wrapper (gradlew) in your repo. (Seemingly that's the situation in your case). It seems to me, however the Gradle wrapper ignores the system default Gradle distribution (set by the GRADLE_HOME env var), and always downloads a Gradle version mandated by the Android Build tools.
Also make sure, that the Android SDK root environment variable (ANDROID_HOME or ANDROID_SDK_ROOT) is pointing to the SDK's root directory (e.g. $ export ANDROID_HOME="/opt/android-sdk/")[1].
Restart Bamboo after applying the environment variable changes.
In Bamboo, in the build tasks lists, add a new Script task. The interpreter should be '/bin/sh or cmd.exe', the script location should be 'inline', and the script body should contain the call for the parametrized Gradle wrapper, e.g.
gradlew clean build
Point the working subdirectory to the Gradle wrapper's relative location (to the repo root), if necessary.
[Sample Bamboo Android Gradle build script]
After these steps, Bamboo should execute the Gradle wrapper, which in fact should perform the actual build steps.
Related
I am attempting to get
https://github.com/KodeinKoders/Playground-Demo-Crypto (commit 2a9b2b9)
Repository to build.
After doing some updates of tooling MacOS & XCode. And addition of the following override to gradle build file:
tasks.getByName<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest>("iosX64Test") {
deviceId = "iPhone 14"
}
I am able to build within command line use
gradle build
On
MacOS: 13.2
XCode: 14.2
However, when I run build within IntelliJ. I get the following error:
Task 'compileJava' is ambiguous in root project 'DemoCrypto'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
The IntelliJ notifications show:
Executing tasks: [:compileDebugSources, :compileDebugUnitTestSources, :compileDebugAndroidTestSources, :compileJava, :testClasses] in project /usr/local/workplace/sandbox-kotlin-thorg/Playground-Demo-Crypto
Prior to build failure.
I am new to gradle. I don't know where this list of tasks that intellij chooses to use for build is coming from? I am also confused by fact that running:
grep -r "compileDebugSources" .
From within the project root leads to 0 matches.
So the questions are:
How does IntelliJ choose to use that particular list of tasks to for its build. Given that compileDebugSources doesnt even exist in the project.
Advice on getting the build to work in IntelliJ?
I have recently updated the version of the Firebase Appdistribution Gradle plugin from 1.4.0 to 2.0.1.
Since then Jenkins started giving the build time error below:
Execution failed for task app:appDistributionUpload[Variant]. Could not find the APK. Make sure you build first by running ./gradlew assemble[Variant], or set the api Path parameter to point to your APK
This is my Gradle script on Jenkins:
... ./gradlew cleanBuildCache :app:testDebugUnitTest :app:appDistributionUpload[Variant] ...
Starting with version 1.4.1 Running appDistributionUpload{Variant} no longer automatically rebuilds the app.
https://firebase.google.com/support/release-notes/android#appdistro_gradle_plugin_v1-4-1
Updating the Gradle script by adding :app:assemble[Variant] before :app:appDistributionUpload[Variant] solved the issue in my case. Hope it will help others as well.
I want to use sync project with gradle file in command line but I dont know how to do
like this :
It besides do ./gradlew build also do other things
For example, in a file is written to a local library name android-test
than in settings.gradle read this file and call include ":${android-test}" .if I use AS sync project with gradle files button,AS can load
module to project , but when I run ./gradlew build, it doesn't work.
But I have developed a plugins, and I want to use this action, so how to call this function ?
Building and syncing from the command line is really simple. In the root of your project you can invoke the gradle wrapper's build command with
./gradlew build
To get a list of all available build tasks for your project:
./gradlew tasks
"./gradlew build" and "./gradlew tasks" in the path of your project.
more commands and steps here:https://developer.android.com/studio/build/building-cmdline.html
The action id is Android.SyncProject, so you can call it in your plugin:
ActionManager.getInstance().getAction("Android.SyncProject").actionPerformed(e);
You can find it in android-plugin.xml, maybe line 161.
Also in SyncProjectAction.java, line 36 you can find its text.
I am trying to pass SVN revision number to our gradle based build machine. It is fine if I use variables like $svnRevision in build.gradle. and run command like "gradlew.bat build -PsvnRevision="1234".
But Android Studio cannot sync and run the build script, Is there a way to set customized arguments for Android Studio Sync Gradle?
You can set default svnRevision in /<project_root>/gradle.properties.
svnRevision=123
Get the parameter in gradle. So gradle task will get this variable when you run sync.
project["svnRevision"]
And you can override this property when you run the gradle command as below.
gradlew -PsvnRevision=456 build
Im playing with Android Studio & Gradle and am interesting in what gradle-aware make actually does. The reason for my interest is I was originally under the impression that the default run config for a new AS projects default gradle-aware make runs the gradle assembledebug command (looking at the status at the bottom of AS during build shows the app:assembleDebug task running) and then some install and run commands.
However in testing on a machine that has 1.9 as the installed system gradle version and a wrapper on the project set to 1.10 I get the following
gradle assembleDebug -> Fail : Could not create plugin of type 'AppPlugin'.
./gradlew assembleDebug -> Success
AS Run -> Success
In my mind the above AS Run should fail if gradle-aware make was using gradle assembledebug
Looking at the src I can see the MakeBeforeRunTaskProvider.java class and the relevant commits but I cant see the relevant info
(have answered my own question as in writing it I sort of found the answer - but I assume if this confused me it will someone else so am posting the simple answer anyhow)
Turns out I shouldve looked in settings as you can set the gradle version that should be used - and it defaults to the "default wrapper".
Now when you create a new project in AS you have a default wrapper set up. You can if you want add a custom wrapper section to your root build.gradle of the form
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
and then run the task with gradle wrapper to update the projects gradle wrapper (in ./gradle/). This allows the wrapper version to easily be updated.
Im assuming the "Use cusomtizable gradle wrapper" option just runs this wrapper task before any other gradle tasks (which could have a custom url for gradle zip download), whereas "use default..." will just used the last generated wrapper. This will be grayed out if the project has no generated wrapper. Please correct me if you think this is wrong.
This is using AS 0.4.6. Annoyingly there is a bug where syncing gradle files will change the project settings here - seems like to what the previous setting was as Im seeing on one project if going to "default..." and the other to "local". Time to upgrade AS!
Also AS's gradle console window shows the exact commands and output