Ansible-playbook for Installing Android SDK - android

How to install Android SDK with ansible-playbook?
I need to configure Jenkins installation playbook and let Ansible configure Jenkins to integrate with Android
So, I have Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
IP = "192.168.33.55"
VM_NAME = "jenkins"
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/ubuntu1604" #target OS: Ubuntu 16.04
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |v|
v.name = VM_NAME
v.memory = 1024
v.cpus = 2
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
config.vm.hostname = VM_NAME
config.vm.network :private_network, ip: IP
config.vm.network "forwarded_port", guest: 80, host: 8080
# Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134
config.vm.define :jenkins do |jenkins|
end
# Ansible provisioner.
config.vm.provision "ansible" do |ansible|
ansible.playbook = "jenkins/playbook.yml"
ansible.inventory_path = "jenkins/inventory"
ansible.sudo = true
end
end
And Jenkins installation playbook:
---
- name: Install Jenkins
hosts: jenkins
gather_facts: yes
vars_files:
- vars/main.yml
pre_tasks:
- name: Install Python for Ansible
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
# changed_when: False
# - setup: # aka gather_facts
become: yes
become_user: root
remote_user: vagrant
vars:
- update_apt_cache: yes
roles:
- base
- geerlingguy.jenkins
- android-sdk
android-sdk role contains file main.yml with tasks:
---
- name: Download Android SDK
action: get_url url=https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip dest=/tmp/android.tgz
- name: Make opt dir for user
action: file path=/opt/adt/ state=directory mode=0777
- name: Unpack Android SDK
action: unarchive copy=no src=/tmp/android.tgz dest=/opt/adt/ creates=/opt/adt//android-sdk-linux
- name: Chown files
action: file path=/opt/adt/android-sdk-linux recurse=yes state=directory
- name: Install Android SDK
action: shell creates=/opt/adt/android-sdk-linux/tools echo y | /opt/adt/android-sdk-linux/tools/android
- name: Configure Android SDK paths
action: lineinfile dest=/home/vagrant/.bashrc line="{{ item }}"
with_items:
- 'export ANDROID_HOME=/opt/adt/android-sdk-linux'
- 'export ANDROID_TOOLS=$ANDROID_HOME/tools/'
- 'export ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools/'
- 'export PATH=$PATH:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS'
So, I run my Vargrantfile:
vagrant up
Roles base and geerlingguy.jenkins works, Jenkins VM successfully up. I can open Jenkins page in my browser.
But then android-sdk role starts work, and I see following:
< TASK [android-sdk : Download Android SDK] >
changed: [jenkins]
< TASK [android-sdk : Make opt dir for user] >
changed: [jenkins]
< TASK [android-sdk : Unpack Android SDK] >
changed: [jenkins]
< TASK [android-sdk : Chown files] >
changed: [jenkins]
< TASK [android-sdk : Install Android SDK] >
fatal: [jenkins]: FAILED! => {"changed": true, "cmd": "echo y |
/opt/adt/android-sdk-linux/tools/android", "delta":
"0:00:00.004105", "end": "2017-07-28 17:17:24.446018", "failed":
true, "rc": 127, "start": "2017-07-28 17:17:24.441913", "stderr":
"/bin/sh: 1: /opt/adt/android-sdk-linux/tools/android: not found",
"stderr_lines": ["/bin/sh: 1: /opt/adt/android-sdk-linux/tools/android: not found"],
"stdout": "", "stdout_lines": []}
jenkins : ok=41 changed=2 unreachable=0
failed=1
Ansible failed to complete successfully. Any error output should
be visible above. Please fix these errors and try again.
But I can see that sdk-tools-linux-3859397.zip contains "tools" directory with "android" shell script inside
My system: Linux Mint 18.2 Sonya, VirtualBox 5.0.40_Ubuntur115130, Ansible 2.3.1.0 and Vagrant 1.9.7.

The 2 main issues are that the unarchive task won't create the /opt/adt/android-sdk-linux directory and that I don't think your command to install the SDK is correct.
As a side note you don't need to use the action module for each task. You can simply replace it with the module inside of the action.
- name: Make opt dir for user
action: file path=/opt/adt/ state=directory mode=0777
Would become
- name: Make opt dir for user
file:
path: /opt/adt/
state: directory
mode: 0777
So to solve your main issues, you first need to create your destination directory before you unpack the android sdk.
- name: Create Android SDK directory
file:
path: /opt/adt/android-sdk-linux
state: directory
- name: Unpack Android SDK
unarchive:
copy: no
src: /tmp/android.tgz
dest: /opt/adt/android-sdk-linux
creates: /opt/adt/android-sdk-linux/tools
I pulled the command to install the SDK of https://gist.github.com/rikyperdana/61b1a5008b757da35a745185bfed7374.
- name: Install Android SDK
shell: yes | ./android update sdk
args:
chdir: /opt/adt/android-sdk-linux/tools

Related

Running sh as part of assembling android project on git action yml

In order for my project to run i need to run a script that building my Cmake folder, so when i do Ci with git action i need to run this :
cd app/src/main/cpp
than
sh build_cmake.sh
I have something like that :
- name: Check out repository code
uses: actions/checkout#v3
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Setting up Cmake
run: |
cd app/src/main/cpp - name: Setting up Cmake
- name: running script
run: |
sh build_cmake.sh
obviously that is not working,
how my goal can be achieve?
You can put both commands in one run:
- name: running script
run: |
cd app/src/main/cpp
sh build_cmake.sh
Another way to solve is to use working-directory (https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun) property:
- name: running script
working-directory: app/src/main/cpp
run: |
sh build_cmake.sh

Gitlab CI Pipeline fails because of ruby issue (Ruby installed)

I'm trying to setup CI on Gitlab. I've got a problem. Looks like runner is working well but each time I try to run pipeline it fails with following error :
Running with gitlab-runner 14.4.0 (4b9e985a)
on local-runner g_SbFiLZ
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on GU33...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Users/xxx/GitLab-Runner/builds/g_SbFiLZ/0/xxx/xxx/.git/
Checking out f4fb6ec9 as main...
git-lfs/2.11.0 (GitHub; windows amd64; go 1.14.2; git 48b28d97)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ gem install bundler
gem : The term 'gem' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script461193448\script.ps1:225 char:1
+ gem install bundler
+ ~~~
+ CategoryInfo : ObjectNotFound: (gem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
I have Ruby installed and setup correctly. I can run gem commands locally. Runner is also set locally so I really dont understand the issue. Here's my gitlab-ci.yml :
stages:
- prepare
- build
- test
- ui-test
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
.setup_bundler: &setup_bundler |
gem install bundler
bundle config
bundle install
.setup: &setup
- *setup_bundler
prepare_project:
stage: prepare
script:
*setup
cache:
key:
files:
- Gemfile.lock
paths:
- vendor
artifacts:
name: "Bundle_${CI_BUILD_NAME}_${CI_COMMIT_REF_NAME}_${CI_BUILD_ID}"
expire_in: 1 day
paths:
- vendor
when: always
when: on_success
tags:
- android
build:
stage: build
script:
- bundle exec fastlane build
dependencies:
- prepare_project
tags:
- android
test:
stage: test
script:
- bundle exec fastlane tests
dependencies:
- prepare_project
tags:
- android
ui-test:
stage: ui-test
script:
- bundle exec fastlane ui_tests
dependencies:
- prepare_project
tags:
- android
Any ideas, pelase ?
It's likely that when you're running gem to debug, you're running it with a different user than gitlab-runner, which is the default gitlab-runner user. Check the PATH setup of your gitlab-runner user, and ensure that gem is on the path.

When uploading apk with the Run wzieba/Firebase-Distribution-Github-Action#v1.3.2 I get the following error

I am trying to upload an apk to firebase using github action.
I have commented out the code analysis and tests to make the action run faster so as to try and resolve the issue. I have also tried to upload an app bundle, I get the same response.
Here is the github action configuration.
name: Deploy app bundle to firebase
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1 # Setup flutter environment
with:
flutter-version: '2.5.0'
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Create env file
run: |
cat << EOF > .env
STAGING_API_BASE_URL="${{ secrets.STAGING_API_BASE_URL }}"
PROD_API_BASE_URL="${{ secrets.PROD_API_BASE_URL }}"
BASE_PATH="${{ secrets.BASE_PATH }}"
EOF
# - run: flutter format --set-exit-if-changed # - run: flutter format --set-exit-if-changed .
#- run: flutter analyze # Analyze the project's Dart code. This causes job to exit
#- name: Run flutter analyze
# run: |
# chmod +x ./flutter_analyze.sh
# ./flutter_analyze.sh
#- run: flutter test # Run Flutter unit tests for the current project.
- name: Build Gradle
run: flutter build apk --debug
- uses: actions/checkout#v2 #This uploads artifacts from your workflow
with:
name: debug-apk
path: build/app/outputs/flutter-apk/app-debug.apk
- run: ls build/app/outputs/flutter-apk
- name: Upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action#v1.3.2
with:
appId: ${{secrets.FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_TOKEN}}
groups: testers
file: build/app/outputs/flutter-apk/app-debug.apk
When I run the workflow I get the following error:
You can use this script to find your built apk path:
run: |
echo "Find build artifacts"
apkPath=$(find app -name "*.apk" | head -1)
echo "Found apk at $apkPath"
if [[ -z ${apkPath} ]]
then
echo "No apks were found, skip publishing to App Distribution"
else
echo "Publishing $apkPath to App Center"
#publish your apk by using $apkPath
fi
it scans all agent files and finds apk file.
use
wzieba/Firebase-Distribution-Github-Action#v1.3.3
I had made a mistake on this line
- uses: actions/upload-artifact #This uploads artifacts from your workflow
The comment is correct but the action is wrong.
I should have used actions/upload-artifact https://github.com/wzieba/Firebase-Distribution-Github-Action/issues/51

Android error while building the Alexa auto SDK

I am trying to build the Alexa auto sdk in Mac OS High Sierra. I am able to successfully build the docker environment required on Mac for the Alexa Auto SDK Builder. While installing the NDK I am getting the following error in terminal `
*******************
*** Docker Mode ***
*******************
NOTE: Run Docker image...
NOTE: SDK Version: 1.2.0
NOTE: Start building for androidarm...
NOTE: Android toolchains will be installed: /workdir/android
NOTE: Checking Android toolchain installation (armeabi-v7a/22)...
NOTE: Installing NDK (android-ndk-r16b)...
NOTE: Downloading file android-ndk-r16b-linux-x86_64.zip
--2018-10-31 05:39:02-- https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
Resolving dl.google.com (dl.google.com)... 216.58.203.142, 2404:6800:4009:802::200e
Connecting to dl.google.com (dl.google.com)|216.58.203.142|:443... connected.
ERROR: cannot verify dl.google.com's certificate, issued by ‘CN=192.168.86.1’:
Self-signed certificate encountered.
To connect to dl.google.com insecurely, use `--no-check-certificate'.
ERROR: Android toolchain setup failed
I tried wget --no-check-certificate https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip `
and downloaded the NDK but the issue is still persisting. Please help as I am stuck.
We have downloaded Alexa-auto-SDK 1.6.
we used the following steps below. Please update docker, my case everything fine working.
mac$ ./builder/build.sh oe -t androidarm --android-api 26
*******************************************************************************
The scripts provided herein will retrieve several third-party libraries,
environments, and/or other software packages at build-time
("External Dependencies") from third-party sources. These are terms and
conditions that you need to agree to abide by if you choose to build the
External Dependencies. Licenses for the External Dependencies may be found at
builder/README.md. If you do not agree with every term and condition
associated with the External Dependencies, enter “QUIT” in the command line
when prompted by the script.
*******************************************************************************
Type "QUIT" to exit the script now, press ENTER to continue:
\e[1mNOTE\e[0m: Builder only runs within Docker with macOS host
\e[1mNOTE\e[0m: Switching to Docker mode...
*******************
*** Docker Mode ***
*******************
+++ dirname /Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/scripts/run-docker.sh
++ cd /Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/scripts
++ pwd
+ THISDIR=/Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/scripts
+ source /Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/scripts/common.sh
++ '[' -z /Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder ']'
+ VM_HOME=/home/builder
+ IMAGE_REVISION=20190128
+ IMAGE_NAME=aac/ubuntu-base:20190128
+ VOLUME_NAME=buildervolume
+ VOLUME_MOUNT_POINT=/workdir
+ [[ '' != \1 ]]
+ TTY=-t
+ EXTRA_OPTIONS=
+ '[' '!' -z ']'
++ docker images -q aac/ubuntu-base:20190128
+ [[ aad39b28847b == '' ]]
++ docker volume ls
++ grep buildervolume
+ [[ local buildervolume == '' ]]
+ note 'Run Docker image...'
+ echo -e '\e[1mNOTE\e[0m: Run Docker image...'
\e[1mNOTE\e[0m: Run Docker image...
+ execute_command aac/builder/build.sh oe -t androidarm --android-api 26
+ docker run -i -t --rm -v buildervolume:/workdir -v /Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/..:/home/builder/aac -e ANDROID_TOOLCHAIN=/workdir/android -e AGL_SDK_BASE=/workdir/agl-sdk -e HOST_PWD=/Users/mac/MetroProject/Android1.5/alexa-auto-sdk -e HOST_SDK_HOME=/Users/mac/MetroProject/Android1.5/alexa-auto-sdk/builder/.. aac/ubuntu-base:20190128 aac/builder/build.sh oe -t androidarm --android-api 26
NOTE: SDK Version: 1.6.0-00002-gb9ee08f-dirty
NOTE: Start building for androidarm...
NOTE: Android toolchains will be installed: /workdir/android
NOTE: Checking Android toolchain installation (armeabi-v7a/26)...
NOTE: Using BUILD_DIR=/workdir/build
Welcome to Alexa Auto Builder!
.c;.
.lKx.
':loooooc' .:c' .c:. .;lkKOocc:. .;looooc,.
.:lc;;;:d00l. ,OKc cK0; 'coOKOocc:. .lOOd:;;cxOk:.
.oKk' ,OKc :0O; .dKx. .oKO; .l00:
.;:::;:dKk' ,OKc :0O; .dKx. ,kKo. 'kKd.
'dOxlc::lkKk' ,OKc :0O; .dKx. ,OKo. .xKd.
.dKk' .lKk' ,OKl. cKO; .dKx. .dKk' :00c
.oKOc...,lkKk' .xKOc'.';cxKO; .oKOl,,,. 'd0kc,..,lO0l.
.:dxxdol;:ol. 'lxkxdol;;lo' .:dxxdo' .;ldxxxxdc'
... ... ....
......
... .',,,;;cc:.
.',,.. .. 'c:.
..,::;,... ...,;;. 'c,
..,:ccc:;,''...... .....'',;:cc;,.. .:,
..',:ccllllcccc:::::::ccccllllc:;'.. ..
...',,;;::::::::;;;,'....
Loading cache: 100% |############################################| Time: 0:00:00
Loaded 1299 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
NOTE: Multiple providers are available for virtual/nativesdk-libintl (nativesdk-gettext, nativesdk-glibc)
Consider defining a PREFERRED_PROVIDER entry to match virtual/nativesdk-libintl
Build Configuration:
BB_VERSION = "1.36.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "ubuntu-16.04"
TARGET_SYS = "arm-linux-androideabi"
MACHINE = "androidarm"
DISTRO = "aac"
DISTRO_VERSION = "1.6.0"
TUNE_FEATURES = "arm armv7a vfp thumb callconvention-hard"
TARGET_FPU = "hard"
meta-aac-ubuntu = "1.6:b9ee08ff5e9a88e1554d1d90f3e368d92cd302cf"
meta = "HEAD:1b18cdf6b8bdb00ff5df165b9ac7bc2b10c87d57"
meta-aac
meta-aac-builder = "1.6:b9ee08ff5e9a88e1554d1d90f3e368d92cd302cf"
Initialising tasks: 100% |#######################################| Time: 0:00:03
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 553 tasks of which 417 didn't need to be rerun and all succeeded.
Thank you

Error when i run sudo rake dtach:install in Rhosync

I'm following the rhosync installation guide.
$rhosync app storemanager-server
$cd storemanager-server
$sudo rake dtach:install
I get the following error:
(in /projects/sharath apps/sharatapp/storemanager-server)
rake aborted!
no such file to load -- rhosync/tasks
/projects/sharath apps/sharatapp/storemanager-server/Rakefile:5:in `require'
(See full trace by running task with --trace)
i dont know where i am going wrong
i tried writing
export RUBYOPT=rubygems
in .profile
but still it not working
when i run gem env commend
this is the following output
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/sharath/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I install dtach as
sudo apt-get install dtach (Ubuntu)
and sloved the problem

Categories

Resources