My aim is to build a Kony Project for the Jenkins CI. So basically I need to know how to build the project on the unix commandline. When using Kony Studio my project builds without issues.
I've already managed to build an android .apk using ant on the build.xml in the project directory. This also builds a .kar file for ios. How do I now trigger the ipa build via xcode using the commandline?
Environment: Mac OSX 10.10.2 with Kony Studio 6.0.
You need to copy the "com.kony.ios_5.5.x.jar" file and rename it to "com.kony.ios_5.5.x.zip".
Unzip the "com.kony.ios_5.5.x.zip",
The unzipped folder contains 5 files, one of it is "**iOS-GA-5.5.x.zip**".
Make sure that you DO NOT delete any of these 5 files.
Unzip the "iOS-GA-5.5.x.zip" , it will give you the "VMAppWithKonylib" folder.
Now, close all the xcodes you might have open.
Then delete data at path Users/(UserName)/Library/Developer/Xcode/DerivedData
Now go to Terminal
Navigates upto Gen folder using cd (e.g. cd /Users/foo/Desktop/VMAppWithKonylib/gen)
Type pearl extract.pl <KAR file path> and launch the Xcode and do a build. (e.g. perl extract.pl /Users/foo/Downloads/konyappiphone-193.kAR)
Now type open <xcodeproj path>. (e.g. open /Users/foo/Desktop/VMAppWithKonylib/VMAppWithKonylib.xcodeproj)
Now the app will run in xcode. Archive and proceed with IPA generation.
EDIT START
As of Kony 7 there is a better way to do headless builds:
http://docs.kony.com/konylibrary/visualizer/visualizer_user_guide/Content/CommandLine.htm
Basically use the HeadlessBuild.properties to configure your build and launch it with ant. It's a struggle in the beginning but we got a successful build of android and iOS via Jenkins.
Note: Building multiple projects at the same time does not seem to work (e.g. for multiple build types) and results in an error message. You'll have to build sequentially.
Comment if you're interested in the further build process and I'll consider writing a blog post about this :)
EDIT END
Finished a first version of a shell script to build a Kony Project for Android and iOS for Jenkins. Its far from elegant or perferct but it might be a good start for anyone who stumbles accross this post.
First I created a settings script which contains the configuration of my build (all values-to-be-entered are shown as <value> tags):
#!/bin/bash
# This script builds a Kony Project with following steps
# 1. Inject settings into global.properties, build.properties, middleware properties
# 2. Build Project by executing ant build.xml
# 2.1 When building android apps these are already packed as .apk
# 2.2 APK is signed
# 3. If iOS app is build the iOS dumyWorkspace (VMAppWithKonylib) is unzipped and filled with KAR file from ant build
# 3.1 the iOS app is archived
# 3.2 this iOS app is signed and exported as ipa
# 4. all APK and IPA files are copied to deploys folder.
# Note: The Directory the Kony Project is inside must be the name of the Kony Project. otherwise it will not build. This means, that if you clone your project from repository you'll have to put it into a folder or already have it checkedin as a folder.
_project_name=<Kony Application Project name. e.g. KonyTemplate>
# Targets
_target_android_phone=true
_target_android_tablet=false
_target_ios_phone=true
_target_ios_tablet=false
# Middleware Config
_middleware_ipaddress=127.0.0.1
_middleware_httpport=8080
_middleware_httpsport=443
# tools
_android_home=<android sdk home>
_android_zipalign=<zipalign in android build-tools>
_eclipse_equinox=<eclipse equinox jar in kony studio. e.g. /Users/userxyz/Kony_Studio/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
_ant_bin_dir=<ant binary directory e.g. /usr/local/bin>
# you will need this parameter if you build an ios project. It is the You can retrieve it like this:
# - search for file "com.kony.ios_x.x.x.GA_vxxxxxxxxxxxx.jar" in Kony_Studio/plugins/ Folder
# - copy it to another folder and rename it as .zip
# - unzip
# - retrieve file "iOS-GA-x.x.x.zip" and copy it to destination referenced in _ios_dummy_project_zip variable
_ios_dummy_project_zip=<location of kony ios workspaced (zipeed). e.g. /Applications/Kony/Kony_Studio/iOS-GA-6.0.2.zip>
# OS Code Signing
_ios_code_sign_identity='<code sign identity>'
_ios_provisioning_profile_uuid='<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>'
_ios_provisioning_profile_name='<provisioning profile name'
# Android signing
_android_storepass=<keystore password>
_android_keyalias=<keystore alias>
_android_keypass=<key password>
_android_keystore=<keystore file within kony project directory. e.g. keystore.jks>
# Settings End
############################################################
# Execute
sh ./jenkins_build_internal.sh $_project_name $_target_android_phone $_target_android_tablet $_target_ios_phone $_target_ios_tablet $_middleware_ipaddress $_middleware_httpport $_middleware_httpsport $_removeprintstatements $_build $_android_home $_eclipse_equinox $_ant_bin_dir $_ios_dummy_project_zip "$_ios_code_sign_identity" "$_ios_provisioning_profile_uuid" "$_ios_provisioning_profile_name" $_android_zipalign $_android_storepass $_android_keyalias $_android_keypass $_android_keystore
I then have the actual script which does the build job as descripted at the top of the first script. Here we also do the Magic which Sam posted.
#!/bin/bash
####################
# Settings
_project_name=$1
# Targets
_target_android_phone=$2
_target_android_tablet=$3
_target_ios_phone=$4
_target_ios_tablet=$5
# Middleware Config
_middleware_ipaddress=$6
_middleware_httpport=$7
_middleware_httpsport=$8
# Build confif
_removeprintstatements=$9
_build=${10}
# Build tools Config
_android_home=${11}
_eclipse_equinox=${12}
_ant_bin_dir=${13}
_ios_dummy_project_zip=${14}
# OS Code Signing
_ios_code_sign_identity=${15}
_ios_provisioning_profile_uuid=${16}
_ios_provisioning_profile_name=${17}
# Android signing
_android_zipalign=${18}
_android_storepass=${19}
_android_keyalias=${20}
_android_keypass=${21}
_android_keystore=${22}
_sleep_while_xcode_startup=15
#######################
# Define functions
function escape_slashes {
sed 's/\//\\\//g'
}
function change_line {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
sed -i .bak '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
mv "${FILE}.bak" /tmp/
}
#######################
# Dump Settings
echo "##### Executing Jenkins Kony Build #####"
echo "# Android Phone = " $_target_android_phone
echo "# Android Tablet = " $_target_android_tablet
echo "# iOS Phone = " $_target_ios_phone
echo "# iOS Tablet = " $_target_ios_tablet
echo "##### Executing Jenkins Kony Build #####"
echo ''
#######################
# Clean
echo "# cleaning up"
rm -rf binaries
rm -rf jssrc
#######################
# Inject properties
echo "# injecting properties"
change_line "^android=" "android=$_target_android_phone" build.properties
change_line "^androidtablet=" "androidtablet=$_target_android_tablet" build.properties
change_line "^iphone=" "iphone=$_target_ios_phone" build.properties
change_line "^ipad=" "ipad=$_target_ios_tablet" build.properties
change_line "^android.home=" "android.home=$_android_home" global.properties
change_line "^eclipse.equinox.path=" "eclipse.equinox.path=$_eclipse_equinox" global.properties
change_line "^httpport=" "httpport=$_middleware_httpport" middleware.properties
change_line "^httpsport=" "httpsport=$_middleware_httpsport" middleware.properties
change_line "^ipaddress=" "ipaddress=$_middleware_ipaddress" middleware.properties
#######################
# Execute Main Build - Ant
echo "## Execute Kony Ant Build - Start ##"
export PATH=$PATH:${_ant_bin_dir}
ant -file build.xml
echo "## Execute Kony Ant Build - Done ##"
echo ''
#######################
# Android app signing
if [ ${_target_android_phone} == "true" -o ${_target_android_tablet} == "true" ]
then
set +x
echo "## Execute Android signing APK - Start ##"
cd binaries/android
jarsigner -storepass "${_android_storepass}" -keypass "${_android_keypass}" -keystore ../../${_android_keystore} luavmandroid.apk ${_android_keyalias} -signedjar luavmandroid-signed_unaligned.apk
${_android_zipalign} -v 4 luavmandroid-signed_unaligned.apk luavmandroid-signed.apk
cd -
echo "## Execute Android signing APK - Done ##"
echo ''
fi
#######################
# Check and execute optional ios Workspace build for iphone
if [ ${_target_ios_phone} == "true" ]
then
echo "## Execute Kony iOS Workspace creation - Start ##"
cd ..
echo "# unzipping workspace #"
rm -rf VMAppWithKonylibiphone
unzip $_ios_dummy_project_zip -d .
mv VMAppWithKonylib VMAppWithKonylibiphone
cd VMAppWithKonylibiphone
cd gen
echo "# filling workspace #"
perl extract.pl ../../webapps/KonyTemplater/kbf/konyappiphone.KAR
# back to ios Workspace
cd ..
echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
# dirty piece of code to create the scheme files... open xcode and close it again :)
echo "# opening project to generate scheme"
open VMAppWithKonylib.xcodeproj
sleep ${_sleep_while_xcode_startup}
echo "# close project"
osascript -e 'quit app "Xcode"'
echo "## Execute Kony iOS Archive - Start ##"
# create signed archive
xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
echo "## Execute Kony iOS Archive - Done ##"
echo "## Execute Kony iOS IPA Generation - Start ##"
# create ipa
xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
echo "## Execute Kony iOS IPA Generation - Done ##"
echo ''
fi
#######################
# Check and execute optional ios Workspace build for ipad
if [ ${_target_ios_tablet} == "true" ]
then
echo "## Execute Kony iOS Workspace creation - Start ##"
cd ..
echo "# unzipping workspace #"
rm -rf VMAppWithKonylibipad
unzip $_ios_dummy_project_zip -d .
mv VMAppWithKonylib VMAppWithKonylibipad
cd VMAppWithKonylibipad
cd gen
echo "# filling workspace #"
perl extract.pl ../../webapps/KonyTemplater/kbf/konyappipad.KAR
# back to ios Workspace
cd ..
echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
echo "# opening project to generate scheme"
open VMAppWithKonylib.xcodeproj
sleep ${_sleep_while_xcode_startup}
echo "# close project"
osascript -e 'quit app "Xcode"'
echo "## Execute Kony iOS Archive - Start ##"
# create signed archive
xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
echo "## Execute Kony iOS Archive - Done ##"
echo "## Execute Kony iOS IPA Generation - Start ##"
# create ipa
xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
echo "## Execute Kony iOS IPA Generation - Done ##"
echo ''
fi
echo "## Copy Binaries to ./deploys/ ##"
cd ..
mkdir deploys
cp VMAppWithKonylibipad/build/KonyiOSApp.ipa deploys/app-release-ipad.ipa
cp VMAppWithKonylibiphone/build/KonyiOSApp.ipa deploys/app-release-iphone.ipa
cp ${_project_name}/binaries/android/luavmandroid-signed.apk deploys/app-release-android.apk
echo ''
echo ''
echo "## JENKINS BUILD SUCCESS ##"
echo ''
In the jenkins configuration I now only call the first script by executing a shell script:
cd KonyTemplate
sh ./jenkins_build.sh
If anyone has any suggestions to improve this little script (and there most definitely are plenty), I'm sure we'll all be happy to hear them.
Related
I want to test the app with android 10 in emulator.So for that I only have "armeabi", "armeabi-v7a","arm64-v8a" in jnilibs. But running app with android 10 device(Emulator), requires x86 abi. So for that first I have downloaded ndk for x86.And the second thing is I want to generate libpjsua2.so for x86 abi.
I am using pjsip library.
I have referred to https://trac.pjsip.org/repos/wiki/Getting-Started/Android. What I have tried is,
1) Downloaded latest pjsip version and extracted in folder.
2) Followed the steps given in pjsip website as below,
$ cd /path/to/your/pjsip/dir
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
$ ./configure-android
$ make dep && make clean && make
$ cd /path/to/your/pjsip/dir
$ make clean
# cleanup pjsua sample app
$ cd pjsip-apps/src/pjsua/android/jni
$ make clean
# also cleanup pjsua2 sample app (SWIG)
$ cd /path/to/your/pjsip/dir
$ cd pjsip-apps/src/swig
$ make clean
$ cd pjsip-apps/src/swig
$ make clean
TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Got error when reached above code,
LDFLAGS = --sysroot= -L/libs/x86/
LIBS = -lgnustl_static -lc -lgcc -ldl
AR = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
RANLIB = /home/Android/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
TARGET_HOST = llvm-linux-android
TARGET_ABI = x86
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `llvm-linux-android': machine `llvm' not recognized
aconfigure: error: /bin/sh ./config.sub llvm-linux-android failed
In my pjsip2.7 folder I found a folder named llvm but that is a empty folder. I doesn't know What is that. I am using cent os 7. Why I am getting this error? What do I need to do to overcome this.
Try compile with this builder
replace in ./config.cong you are using 2.10
# PJSIP Version to download
PJSIP_VERSION=2.10
./prepare-build-system
and then
./build
Android Studio is too slow for my computer so I took it upon myself to learn how to build android apps manually. I finished with this script:
#!/usr/bin/env bash
##################################################################
# PREPARE ENVIRONMENT
##################################################################
path=$(pwd)
rm -rf bin
rm -rf gen
mkdir bin
mkdir gen
##################################################################
# SET VARS
##################################################################
# Set your application name
APP_NAME="mygame"
# Define minimal Android revision
ANDROID_REV="27.0.3"
ANDROID_PLATFORM_REV="android-27"
# Define Java compiler command
JAVAC="${JAVA_BIN}/javac -classpath ${ANDROID_SDK}/platforms/${ANDROID_PLATFORM_REV}/android.jar"
JAVAC_BUILD="${JAVAC} -sourcepath src -sourcepath gen -d bin"
##################################################################
# PROCESS
##################################################################
# Generate R class and pack resources and assets into resources.ap_ file
${ANDROID_SDK}/build-tools/${ANDROID_REV}/aapt package -v -f -I ${ANDROID_SDK}/platforms/${ANDROID_PLATFORM_REV}/android.jar -M AndroidManifest.xml -A "assets" -S "res" -m -J "gen" -F bin/resources.ap_
# Compile sources. All *.class files will be put into the bin folder
${JAVAC_BUILD} src/com/mycompany/mygame/*.java
# Generate dex files with compiled Java classes
${ANDROID_SDK}/build-tools/${ANDROID_REV}/dx --dex --output=${path}/bin/classes.dex ${path}/bin
# Recources file need to be copied. This is needed for signing.
mv "${path}/bin/resources.ap_" "${path}/bin/${APP_NAME}.ap_"
# Add generated classes.dex file into application package
${ANDROID_SDK}/build-tools/${ANDROID_REV}/aapt add ${path}/bin/${APP_NAME}.ap_ ${path}/bin/classes.dex
${ANDROID_SDK}/build-tools/${ANDROID_REV}/zipalign -f -v 4 ${path}/bin/${APP_NAME}.ap_ ${path}/bin/${APP_NAME}_unsigned.ap_
# Create signed Android application from *.ap_ file.
${ANDROID_SDK}/build-tools/${ANDROID_REV}/apksigner sign --ks ${path}/keystore/etamagotchi-release-key.keystore --ks-key-alias "mykeystore-alias" ${path}/bin/${APP_NAME}_unsigned.ap_
#
cp ${path}/bin/${APP_NAME}_unsigned.ap_ ${path}/bin/${APP_NAME}.apk
# Delete temp file
rm bin/*.ap_
rm bin/*.dex
It builds successfully. If I try to run adb install mygame.apk it says:
[INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.mycompany.mygame-1: Package /data/app/com.mycompany.mygame-1/base.apk code is missing]
If I manually try to install it says "The package appears to be corrupted". What's wrong with my build script?
I added -source 1.7 -target 1.7 -bootclasspath "${JAVA_HOME}/jre/lib/rt.jar" to my $JAVAC build rule
It is possible to implement Continuous Integration for a React Native app using Jenkins? I haven't found a guide to do this. If there are also other solution, what is the best one? Also, a Mac OS machine is mandatory for iOS project?
Yes, it is totally possible. You only have to execute all actions from the command line instead of XCode or the IDE of your choice. In the case of iOS, have a look at the react-native bundle command to create the JS bundle and xcodebuild and xcrun for compiling the native code. In Android it is a bit easier, since you have the gradle assembleRelease task. Before that you have to run npm install to get all your dependencies, but that should roughly be it.
As for iOS development, unfortunately there is no way around it, you do need an OS X machine.
The first thing is to get a command line build working for both Android and iOS. You can peak at the Xcode or Android Studio logs and copy some of the commands.
I put a build.sh script in the ios and android folders that I can call from a Jenkins job to build respective targets. You could have a build.sh in your project root that calls both.
Todo: I want to figure out how to run eslint airbnb in a Jenkins job and generate a report?
Here is my iOS build.sh script that works with Xcode 9:
#!/bin/sh
############################################
# File: build.sh
# -----------------------
# Author: edOfTheMountain#acme.com
#
# Command line build:
# 1) clean
# 2) build
# 3) archive
# 4) export IPA
#
# http://shashikantjagtap.net/xcodebuild-deploy-ios-app-command-line/
# https://help.apple.com/itc/apploader/e3#/apdATD1E53-D1E1A1303-D1E53A1126
#
isInPath=$(which xcodebuild)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcodebuild not found in path"
exit 1
fi
isInPath=$(which xcrun)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcrun not found in path"
exit 1
fi
echo "### Start: Cleaning ###############################################################"
rm -rf build
xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS clean
echo "### Done: Cleaning ###############################################################"
# Analyze
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos clean analyze
echo "### Start: Building ###############################################################"
# xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS build
# Run pod install once before building workspace
pod install
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -destination generic/platform=iOS build
echo "### Done: Building ###############################################################"
CFBundleShortVersionString=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ./MyApp/Info.plist`
CFBundleVersion=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" ./MyApp/Info.plist`
echo "CFBundleShortVersionString: ${CFBundleShortVersionString}"
echo "CFBundleVersion: ${CFBundleVersion}"
ipaFileName=MyApp.ipa
renameIpaFileName="field-scout-${CFBundleShortVersionString}.${CFBundleVersion}.ipa"
echo "### Start: Archiving ###############################################################"
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
echo "### Done: Archiving ###############################################################"
echo "### Start: Exporting ###############################################################"
xcodebuild -exportArchive -archivePath $PWD/build/MyApp.xcarchive -exportOptionsPlist MyApp/ExportOptions.plist -exportPath $PWD/build
ls -al build
echo "### Done: Exporting ###############################################################"
appArchiveFile=build/${ipaFileName}
if [ ! -f "${appArchiveFile}" ]; then
echo "*** Error file not found: ${appArchiveFile}"
exit 1
fi
# Extract and verify archive contents
echo "### Unzip: ${ipaFileName} ###############################################################"
( cd build; unzip -q ${ipaFileName} )
( cd build/Payload; xcrun codesign -dv MyApp.app/ )
outputFile=build/Payload/MyApp.app
if [ ! -d "${outputFile}" ]; then
echo "*** Error file not found: ${outputFile}"
exit 1
fi
rm -rf ./build/Payload
rm -rf ./build/Symbols
# altool is used to verify iOS IPA files
altool_path=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/Current/Support
isInPath=$(which altool)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error altool not found in path"
echo "Expected altool path:\n ${altool_path}"
exit 1
fi
# altool validate will trigger a user dialog first time it is run.
# On a jenkins slave you will need to execute manually in a console once, to allow keychain access.
# $ altool --validate-app -f file -u username [-p password] [--output-format xml]
# $ altool --upload-app -f file -u username [-p password] [--output-format xml]
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com"
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" --output-format xml > build/validate.xml
altoolValidate=$?
if [ ${altoolValidate} -ne 0 ]; then
echo "*** Error IPA failed to validate: build/${ipaFileName}"
echo "See: build/validate.xml"
exit 1
fi
echo "Rename build/${ipaFileName} to build/${renameIpaFileName}"
mv ./build/${ipaFileName} ./build/${renameIpaFileName}
echo ##############################
echo Done
echo ##############################
echo Ready to upload archive to iTunes:
echo " ${appArchiveFile}"
echo
uploadExample="$( echo altool --upload-app -f build/${renameIpaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" )"
echo "Upload Example:\n ${uploadExample}"
echo
I am having issues opening the files that contains IntelliJ IDEA Inspection warnings using Jenkins and Warnings Plugin.
The path to my files looks weird - file://$PROJECT_DIR$/app/src/main..../Foo.java in the .xml generated files by ./inspect.sh
When I click on the file I get the following error:
`java.io.IOException: Failed to copy file:/$PROJECT_DIR$/app/src/main/java`/
These are some screenshots of my files:
I am using the ./inspect.sh from Android Studio, not from actual IntelliJ. Could that be the problem?
Thanks in advance.
In the end I have added an extra build step where I clean the .xml files that are output by ./inspect.sh.
I have also added a line of code that removes all the inspects related to the build (generated) directory. Hope this helps anyone who was stuck with this issue.
Below you have the tweaked inspect.sh file and the two separate build steps:
inspect.sh
#!/bin/sh
#
# ------------------------------------------------------
# Android Studio offline inspection script.
# ------------------------------------------------------
#
export DEFAULT_PROJECT_PATH="$(pwd)"
cd ..
exec "MacOS/studio" inspect "$#"
Build Step 1
cd ${WORKSPACE}/inspectionsresults
rm *.xml
cd "${ANDROID_STUDIO_HOME_BIN}"
./inspect.sh ${WORKSPACE} ${WORKSPACE}/inspections_profile.xml ${WORKSPACE}/inspectionsresults -v2 -d ${WORKSPACE}/app
Build Step 2
cd ${WORKSPACE}/inspectionsresults
sed -i .bak "s,file://\\\$PROJECT_DIR\\\$,${WORKSPACE},g" *.xml
sed -i .bak "s,file:///,,g" *.xml
/usr/local/bin/xml ed -L -d "/problems/problem[contains(file,'generated')]" *.xml
rm *.bak
I have used xmlstarlet to remove the "generated" problems.
brew install xmlstarlet
please tell me how to build apk files of a project without the use of ECLIPSE ide. i found some infos about using a batch file but i don't know how to remake it.
echo on
SET PREV_PATH=%CD%
cd /d %0\..
REM Clear bin folder
rmdir "bin" /S /Q
rmdir "gen" /S /Q
mkdir "bin" || goto EXIT
mkdir "gen" || goto EXIT
REM Set your application name
SET APP_NAME=SecureSms
REM Define minimal Android revision
SET ANDROID_REV=android-8
REM Define aapt add command
SET ANDROID_AAPT_ADD="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" add
REM Define aapt pack and generate resources command
SET ANDROID_AAPT_PACK="%ANDROID-SDK%\platforms\%ANDROID_REV%\tools\aapt.exe" package -v -f -I "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
REM Define class file generator command
SET ANDROID_DX="%ANDROID-SDK%\platform-tools\dx.bat" --dex
REM Define Java compiler command
SET JAVAC="%JAVABIN%\javac.exe" -classpath "%ANDROID-SDK%\platforms\%ANDROID_REV%\android.jar"
SET JAVAC_BUILD=%JAVAC% -sourcepath "src;gen" -d "bin"
REM Generate R class and pack resources and assets into resources.ap_ file
call %ANDROID_AAPT_PACK% -M "AndroidManifest.xml" -A "assets" -S "res" -m -J "gen" -F "bin\resources.ap_" || goto EXIT
REM Compile sources. All *.class files will be put into the bin folder
call %JAVAC_BUILD% src\org\secure\sms\*.java || goto EXIT
REM Generate dex files with compiled Java classes
call %ANDROID_DX% --output="%CD%\bin\classes.dex" %CD%\bin || goto EXIT
REM Recources file need to be copied. This is needed for signing.
copy "%CD%\bin\resources.ap_" "%CD%\bin\%APP_NAME%.ap_" || goto EXIT
REM Add generated classes.dex file into application package
call %ANDROID_AAPT_ADD% "%CD%\bin\%APP_NAME%.ap_" "%CD%\bin\classes.dex" || goto EXIT
REM Create signed Android application from *.ap_ file. Output and Input files must be different.
call "%JAVABIN%\jarsigner" -keystore "%CD%\keystore\my-release-key.keystore" -storepass "password" -keypass "password" -signedjar "%CD%\bin\%APP_NAME%.apk" "%CD%\bin\%APP_NAME%.ap_" "alias_name" || goto EXIT
REM Delete temp file
del "bin\%APP_NAME%.ap_"
:EXIT
cd "%PREV_PATH%"
ENDLOCAL
exit /b %ERRORLEVEL%
i got this codes from a site. (http://www.apriorit.com/our-company/dev-blog/233-how-to-build-apk-file-from-command-line)
i downloaded the source code sample and opened the batch file in there but it didn't generate it's apk file. usually the apk file is located at its bin\ right? but when i opened the folder, the file is not in there. please help me how to use this one. i'd appreciate you help.
You’ll have to have Apache ant for this one:
ant debug
This will build and sign the necessary .apk files.
For more info, please see this: http://codeseekah.com/2012/02/09/command-line-android-development-basics/
EDIT:
ant is not a part of standard Android SDK setup. You'll have to install it.
Download the latest ant zip file from The Apache Ant Project.
Extract the zip file to a folder, say c:\ant\
Add c:\ant to your path environment variable
Once these are done, you'll be able to run ant from the command line
The apk by default is located under bin and this is correct, but when you distribute source code it's better to not add any apk because a "fresh" compiled apk is always a better solution.
if you have a file called build.xml in the root of your project just do
ant debug
otherwise you need to update your project with the minimum informations required for the building phase with
android update project -t android-10 -p .
in this case android-10 is a target for your apk/app/api and you can customize this option for your targeted device.
After this you get your build.xml and everything is in place for generating an apk.
ant debug install
is actually viable if you create project with (note that you should specify the virtual device with "adb -s" command while installing if you're running multiple devices)
android create project -n <project_name>
-t <target_version> -p <path> -k <package> -a <activity>
and use this command to run on the avd (if you've started one)
adb -e shell "am start -a android.intent.action.MAIN -n com.your.package/.YourActivity"
(change -e option to -d if you're running on devices)
reference
better use "AVD Manager.exe" to start a virtual device if you don't know those command or parameters, as there're quite a lot.
One of the best example I found on Internet for creating Android APK is https://geosoft.no/development/android.html.Also you can use assembleDebug command in root directory (make sure setting gradle as environment variable), if you are using Gradle.