I have installed Jenkins on my ubuntu 11.04 system using command "apt-get install jenkins".
I am able to executes "ant debug" command from linux command line well and completed successfully But when i am trying to debug Android project from git hub using jenkins frontend by setting build target "Invoke ant" with properties "sdk.dir=/opt/android-sdk-linux-ics". It is giving following error Console Output :
########################################################################################
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/touchanimtn
Checkout:touchanimtn / /var/lib/jenkins/workspace/touchanimtn - hudson.remoting.LocalChannel#72cd429b
Using strategy: Default
Last Built Revision: Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://github.com/ssamar/touchanimtn.git
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Checking out Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
[touchanimtn] $ ant -Dsdk.dir=/opt/android-sdk-linux-ics clean debug
Buildfile: /var/lib/jenkins/workspace/touchanimtn/build.xml
BUILD FAILED
/var/lib/jenkins/workspace/touchanimtn/build.xml:83: Cannot find /opt/android-sdk-linux-ics/tools/ant/build.xml imported from /var/lib/jenkins/workspace/touchanimtn/build.xml
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
###################################################################################
I also tried by putting "android-sdk-linux-ics" into home folder but gave same error.
Please, Give me the correct solution for this error.
Either the root of your Android SDK isn't at /opt/android-sdk-linux-ics (i.e. the tools directory should be in there, with no intermediate directories), or the SDK does exist there, but the jenkins user doesn't have permission to access it.
This is a good question that more people will face when installing Jenkins on a linux system where the android SDK was installed before.
The problem is either that the path to the android SDK is not correct (1) or insufficient permissions for the jenkins user to access the android SDK installation path (2).
1) Path: Double check the path on your ant build step for the failing jenkins project. Go to the ant build step and click advanced. There it should have sdk.dir=SOME/PATH listed in the properties field. For multiple values make sure you expand the field and use a new line per value. Also don't include the -D to your argument since Jenkins will do that for each line.
2) Permissions: Double check the permissions on the android-sdk folder listed there. Use ls -l to get a list of current permissions and chmod to update the permissions if needed.
Notes:
It's always a good idea to switch to the jenkins user on your system and test the failing commands from the shell yourself.
sudo su jenkins
I had this kind of error also when I enabled security on my jenkins configuration. You can disable security without loosing settings by stopping the jenkins service, renaming the config file and restarting the service.
sudo service jenkins stop
sudo mv /var/lib/config.xml /var/lib/config.xml.backup
sudo service jenkins start
I didn't check in depth what user should get permissions in that case but I know reverting this change fixed the issue. Also I could still execute the ant scripts with the jenkins user as listed before.
This questions is very similar: Building android project from jenkins under linux - build fails, cannot find imported build.xml
Might help someone.
Wherever ANDROID_HOME/platforms pointing to
Reach in finder
bring get info
add Jenkins user and
give read access.
This solved my problem of build.xml not found error.
Related
everyone. I want to build an app for one of my clients. It's the first time I develop an app on Ionic 4 and at the time of building the apk, I couldn't do it.
I checked all the errors that the console prompted to me. At first, it seemed to be moving on, however, at a moment, the console prompted the following:
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/Cris/Library/Android/sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
I have already done a research about this topic, and even though there are similar questions here on this website, I couldn't find any answer that solved my problem.
I have already defined the ANDROID_SDK_ROOT, the ANDROID_HOME and GRADLE_HOME. I checked all of those dirs to see if they worked, and they did so. I have already downloaded and set up the JDK variable and path as well.
I have installed Android Studio with the version of sdk API that I need for this development. Also, when I researched about gradle, I installed it with npm and manually (without counting the time it got installed automatically with Android Studio). HOWEVER!!! The console tells that gradle isn't installed, that Android paths aren't set or that they are deprecated (both options, actually), and that I have to do what I have already done several times.
Here I let you see the variables set:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export ANDROID_HOME=/Users/Cris/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export GRADLE_HOME=/Users/Cris/Library/Gradle.0/bin
export PATH=$PATH:$GRADLE_HOME
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
Do you guys have any idea of how to proceed? Thank you before hand
GRADLE_HOME should be the root folder of the <gradle installation folder>, currently its pointing to <gradle installation folder>/bin it should look like following
export GRADLE_HOME=/Users/Cris/Library/Gradle.0
I have already overcame the problem with the following instructions:
When you want to build your app for Android with Ionic 4 on MAC, install Java (JDK), install Android Studio, install the API version you want to work with, install Homebrew (on its website there is a so easy-to-follow guide to install it) and install Gradle by writing the following command:
brew install gradle
Then, write the following command and copy the route of the gradle directory:
brew info gradle
Go to Ionic Framework Developer Resources for MAC
And follow the instructions to set up the paths. Don't forget to check if the example paths work just fine on your computer by doing it as the following example:
ls /Users/your-user/Library/gradle-5.4
If the "echo" of that line says that the directory exists, then it's okay and you must set that path the way it is. If the directory doesn't exists (as it'll happen in the case of the $GRADLE_HOME's path, you should paste the route that you copied some steps ago.
To corroborate that those paths exist on your MAC, besids saving them on your MAC's ~/.bash_profile, enter them one by one (exporting the variable and exporting its path) inside the MAC's terminal.
Then, as one of the last steps (I'm not going to describe how to sign your app, because it's explained on the link above), write on a console opened inside your project the following line:
sudo ionic cordova build android --prod
It's going to build your app for production, which releases you from signing your app in order to install it on your mobile device
IMPORTANT NOTE:
If you want to sign your app, you should run the following command before signing it (it replaces the last command I wrote above):
sudo ionic cordova build --release android
You can find more information about releasing your app without a signed key and how to sign it on this website's section:
Publishing Your App - Ionic Framework
Thank you for checking this answer out! :D
I'm configuring my build pipeline for an Android project. So far, all of my steps are working perfectly on Hosted VS2017 agent, including fetching the code, building with gradlew, publishing the artifact and deploying it to AppCenter.
However, on Hosted Ubuntu 1604, there are a few problems with gradlew step.
On VS2017 agent, this works with just: .\gradlew assembleDebug
On Ubuntu 1604, this is what I'm having right now:
chmod 775 gradlew
chmod 775 /usr/local/lib/android/sdk --> The fix I'm working on
./gradlew assembleDebug
Running the build without the 2nd line, agent will throw this exception:
What went wrong: A problem occurred configuring project ':app'.
Failed to install the following SDK components: build-tools;28.0.3 Android SDK Build-Tools 28.0.3
The SDK directory is not writable (/usr/local/lib/android/sdk)
I'm a beginner with Ubuntu... why is it not writable? I tried to chmod but I got the exception while doing so: chmod: changing permissions of '/usr/local/lib/android/sdk': Operation not permitted.
Which direction should I look at to solve this problem now... ? Thank you all in advance!
Change the ownership of Android SDK:
sudo chown -R $(whoami) $ANDROID_HOME
I had the same problem on a standard Ubuntu install.
The solution: install the Android SDK in your home directory.
The problem is, building a project with Gradle fails to work with a read-only SDK. Installing the Android SDK with apt leaves it read-only.
More precisely, everything in /usr/ is supposed to be read-only data, so it's owned by root with permissions set to 755. Your user doesn't have write access to it, only the owner does. Installing the SDK in your home directory (and making sure your user owns it) should solve the issue.
Installing the SDK
I haven't seen a good way to install just the SDK. There's another SO question addressing this; one of the ways listed there ought to work.
However, you may find it easier to just install Android Studio, and pick a custom location for the SDK.
Hope it helps!
there is no need to reinstall something at all...
giving the write privilege to the currently logged in user solves the problem.
I have an android project which I'm developing in windows environment.
Also a remote git repository exist which I push my project to it daily.
My requirement is to have a mechanism to automate daily(or nightly) builds.
I know that I can build my project in command line by aid of "gardlew.bat". This wrapper is special to my environment (windows) and I need to build the project on remote git repository which is on a linux machine.
How can i build my project on a linux machine using command line?
As part of your project's root files, you can find "gradlew.bat" that is meant to run on windows machines, and a "gradlew" file that is meant to run on a unix based system.
To build from unix command line, clone your entire project into the linux based machine and run the following command:
./gradlew assembleRelease
You need to make sure that your environment is set up correctly (JDK is installed and JAVA_HOME is configured correctly).
For detailed explanation, please refer to the Android Studio developers site for more information.
You can install Jenkins and configure a job for building (and testing, if you have some tests) your application. Configure this job to run periodically (via embedded cron).
Jenkins can
clone source code from the repo
run gradle with the task(s) specified
save *.apk (save artifacts in Jenkins terminology)
run tests
and many other useful things you may be interested in
Consult https://jenkins.io/index.html
I am setting up Jenkins to clone my git project, update the project, then build using ant. If I perform an ls in the job after cloning the repo, I see my project.properties file present (containing target).
To update the project (and therefore generate the build.xml file) I issue the following command:
android update project -p ./
However, I get the following console output:
Error: The project either has no target set or the target is invalid.
Does anyone know how to update an android project from Jenkins and avoid this problem?
So you've eliminated the first part of the error (i.e. the project does have a target set), but not the second part.
The message "target is invalid" means that you don't have the target platform installed in the Android SDK that Jenkins is using.
e.g. if your target is android-17, then you need to install the Android 4.2 platform (for example via the command android update sdk -u -t android-17).
As an aside, you can automate both the relevant calls to android update -p and the installation of required target platforms using the Android Emulator Plugin for Jenkins.
I have tried using Jenkins with my Android project which I'm using Maven for. I have tried following this tutorial except the emulator part since I don't have any tests (yet). http://vitorbaptista.com/continuous-integration-for-android-apps-with-jenkins-and-maven3/
I am getting the following error when I try building my project in Jenkins:
message : Failed to execute goal
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.3.0:generate-sources
(default-generate-sources) on project ....: Execution
default-generate-sources of goal
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.3.0:generate-sources
failed: Could not find tool 'aapt'. Please provide a proper Android
SDK directory path as configuration parameter
... in the plugin . As an
alternative, you may add the parameter to commandline:
-Dandroid.sdk.path=... or set environment variable ANDROID_HOME. cause : Execution default-generate-sources of goal
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.3.0:generate-sources
failed: Could not find tool 'aapt'. Please provide a proper Android
SDK directory path as configuration parameter
... in the plugin . As an
alternative, you may add the parameter to commandline:
-Dandroid.sdk.path=... or set environment variable ANDROID_HOME.
Here is my configuration for Android and Maven:
Jenkins
(that folder is the right one, I've checked a million times)
Project
I have tried even chmod 777'ing the path to my SDK directory in the case Jenkins doesn't have access.
Any ideas?
Unfortunately, it was as simple as installing the platform tools. Since I have always worked with the SDK via UI, I haven't thought about the installation of the platform tools. After installing the platform tools, everything built.
The command was as simple as:
[sdkdir]/tools/android update sdk --no-ui --filter platform-tool