1. Edit app/build.gradle:
android { compileSdkVersion 23buildToolsVersion "23.0.1" def jenkinsBuild = System.getenv("BUILD_NUMBER") ?: "10" defaultConfig { applicationId "andres_sjsu.notegit"minSdkVersion 16targetSdkVersion 23versionCode jenkinsBuild.toInteger() versionName "1."+ versionCode}
2. Commit your code to Github.
3. Kick a build from Jenkins.
4. Now the apk will have the versionCode injected by Jenkins build #. Example is your Jenkins project build is number 118 the versionCode will be 118 (Jenkins build number increments by one, which is perfect since every time you publish to Google Play Market the developer needs to increment the versionCode by one, otherwise the Play Market will not let you update your apk).
5. To verify the versionCode was incremented correctly, you can use the buid-tool aapt
$./aapt dump badging /Users/andres/Downloads/app-debug2.apk
It will output info about Android package, example below:
You can see the results are as expected:
versionCode: 118 (Jenkins project build #)
versionName: 1.118
TODO: add versionName to apk name, this will help to easier see the app user(QA, Dev,..) installs.
Example of app Name: qa-go90_1.0.12.apk, release-go90_1.0.12.apk, etc...
FYI:
aapt location is in your android/build-tools
ex:
$cd /Applications/adt-bundle-mac-x86_64-20131030/sdk/build-tools/android-4.4
$./aapt d badging myapk.apk | grep package
Output
TUSCA09TMLVT029:23.0.2 v644084$ ./aapt d badging /Users/Desktop/base.apk | grep package
package: name='com.myPackageName.release'
versionCode='97040'
versionName='1.7.0'
platformBuildVersionName='6.0-2166767'
Resources:
http://developer.android.com/intl/es/tools/publishing/versioning.html
Configure gradle: https://developer.android.com/intl/es/tools/building/configuring-gradle.html
good read:* http://www.androidshortcuts.com/tags/gradle/
http://eric-liang.com/category/android-app-development/
No comments:
Post a Comment