Newbie with Bamboo trying to produce .apk for android application.
I have done the checkout and gradlew build tasks for default job, so the download and build process is fine.
What I need is to be able to produce signed .apk file and deliver it in someway to other part of our team.
Thinking about modify the gradle script to produce signed .apk with keystore/password and so, but not sure how to configure Bamboo to serve the .apk.
Any help much appreciated.
Building a signed APK is a function of your Gradle build script and not Bamboo. Based on the information available here, this is how I build a signed APK using Gradle. The information under the "Signing Your App in Android Studio" section is particularly helpful to create the keystore and the key necessary to sign the APK.
// APK signing configuration
android.signingConfigs {
MobileApp {
storeFile file("${rootDir}/TempKeyStore.jks")
storePassword "********"
keyAlias "********"
keyPassword "********"
}
}
// Build types - debug and release both use signing config above to
// sign the resultant APKs
android.buildTypes {
debug {
signingConfig android.signingConfigs.MobileApp
}
release {
signingConfig android.signingConfigs.MobileApp
}
}
Once you have your Gradle build script configured to build a signed APK, Bamboo can be easily configured to run your Gradle build script.
Related
I am developing for a closed platform and need to sign my apk with platform keys to be able to read from certain protected libraries. since this app additionally is not available on the Google Play store, does this mean that I don't need to sign with any other public private key pair for a release build? currently my workflow is such that we first create the build with gradlew assembleRelease which I assume uses the local.properties to sign my apk given the current build.gradle setup:
release {
keyAlias 'androiddebugkey'
keyPassword 'android'
storeFile file('./debug.keystore')
storePassword 'android'
}
if I am subsequently using apksigner to sign with the platform credentials, does that render the aforementioned release build.gradle config pointless?
So it looks like the gradle configuration is used for a particular build type, or the alternative is to use zipalign and apksigner on the apk generated from the gradle task. So if i wanted to continue using apksigner i should remove the build.gradle configuration. I guess theoretically it was signing again the app twice, but since the last one was the non-debug keys, it didn't really matter.
For reference:
https://developer.android.com/studio/build/building-cmdline#gradle_signing
When I share my apk through Google Drive or any means App is not getting installed on some phones. But when I install it through ADB it is getting installed. What could be the problem?
there are many reason , maybe you use native code , or issue with signing.
try to install though ADB in release variant and check the error .
in android section at your app level gradle file "build.gradle module app add your signing config
.........
android {
signingConfigs {
config {
storeFile file('path to your keystore file')
storePassword 'keystorePassword'
keyAlias 'alias'
keyPassword 'aliesPassword'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
.......
then from the left side click build variant and choose release
now run your app and you should get the same result as install the APK from file manager or what ever .
If you are using Android studio 3.0 above version and trying to build an APK then go to
Go to build
2: Build bundles
3: Build APK(s)
and then share the build. It will surely get installed in any devices.
Just make sure Device has allowed APK install from other resources.
I am running into the following message when attempting to upload my APK as an alpha release on Google Play.
'You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play.'
In my gradle I have configured the signing config and build type(s) as follows:
signingConfigs {
release {
storeFile file("PATH TO KEY STORE")
storePassword "STORE PASSWORD"
keyAlias "ALIAS"
keyPassword "PASSWORD"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
testCoverageEnabled true
debuggable false
}
debug { testCoverageEnabled true }
}
Furthermore, I've verified using jarsigner that my APK was signed and that the CN does not contain CN=Android Debug.
The manifest for the APK does not contain the attribute android:debuggable.
The application I've built is a Kotlin application with the following dependencies:
Android Support v13 27.0.2
Android Support Annotations 27.0.2
Android Support Constraint Layout 1.0.2
Junit 4.12
Mockito 2.15.0
Robolectric 3.7
Android Support Test Runner 1.0.1
Android Support Test Espresso Core 3.0.1
I've attempted to upload the APK generated via gradle command line (i.e., gradle build) as well as the APK generated from the IDE using Build, Generate
Signed APK, and I've ensured that the release variant is selected when building from the IDE and gradle before attempting to upload to Google Play.
Finally, I've attempted this with multiple keystores (creating a new one thinking that perhaps my first one was invalid), and still I cannot upload my APK. To clarify, this is the first apk upload. No prior version exists on Google Play.
Is one of the support libraries leading to this issue, or is there something I have missed?
I discovered the issue.
It seems an APK with test coverage enabled is considered debuggable.
After removing the line
testCoverageEnabled true
from my release build type, I was able to upload my APK.
I have some android instrumented tests under AndroidTests directory in Android Studio. Of course I can manually execute the tests but I need to execute all the tests in the suite after each build ("release" type of build, not during normal debug build). I need to do that because I'd like to validate the new code against the tests before releasing the new app's apk. How to do that? I google it but I didn't find a proper solution yet.
Any idea?
Finally I managed to do that. I have added the following configuration to my build.gradle file in my android studio project:
// execute android tests before realising a new apk
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease')
task.dependsOn('connectedAndroidTest')
}
android {
signingConfigs {
release {
keyAlias 'key'
keyPassword 'password'
storeFile file('/path/to/release_keystore.jks')
storePassword 'password'
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
}
}
After doing that I'm able to run all android tests when building a release apk. If the tests are failing no apk is built.
In general you can define a dependencies for the task using the dependsOn method.
For example:
task A << {
println 'Hello from A'
}
task B << {
println 'Hello from B'
}
B.dependsOn A
You will obtain
> gradle -q B
Hello from A
Hello from B
In your case you can specify:
assemble.dependsOn test
If you would like to specify a dependency only for the release build:
assembleRelease.dependsOn test
Use:
connectedAndroidTest to run the tests on a connected emulator or device.
test to run the unit test on your local host.
I think you should dive in one certain topic: Continuous Integration.
This would allow you to run tests suites after every build or commit, build variants, publish on Google Play and much more... Start with classic Jenkins CI, which may not be the most polished and easy to use, I mean user-friendly tool, but in compare to Travis or Circle CI it provides huge configuration possibilities, nice app community and it's free to use.
Start with this article: http://www.vogella.com/tutorials/Jenkins/article.html
Other tools: I'm already using Travis for my Github projects, but Circle CI or Green House CI might be also good choice.
Hope it will help
How can I deploy and publish an Android app made with React Native to Google Play?
Steps:
Create and then copy a keystore file to android/app
keytool -genkey -v -keystore mykeystore.keystore -alias mykeyalias -keyalg RSA -keysize 2048 -validity 10000
Setup your gradle variables in android/gradle.properties
MYAPP_RELEASE_STORE_FILE=mykeystore.keystore
MYAPP_RELEASE_KEY_ALIAS=mykeyalias
MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
Add signing config to android/app/build.gradle
defaultConfig { ... }
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
Generate your release APK cd android && ./gradlew assembleRelease
Upload android/app/build/outputs/apk/app-release.apk to Google Play
Resource: React Native Publishing an Android App
What you want to do is creating a javascript bundle and after that compile the app using gradle. Currently(react-native v0.11) the bundle command only supports generating iOS bundles.
I found a description how to get the android bundle and generate an APK. See https://github.com/facebook/react-native/issues/2712 or https://github.com/facebook/react-native/issues/2743#issuecomment-140697340
Hope this helps.
-- Edit as of 2016 25th of May (v0.26.1 as stable)
Currently it's pretty easy to generate a production APK.
cd android
./gradlew assembleRelease
And now you should have a production APK. You should be able to sign the APK http://facebook.github.io/react-native/docs/signed-apk-android.html#content
React Native is very new in the market, the only guide for android is it's official guide
https://facebook.github.io/react-native/docs/android-setup.html
it'll take time for people to learn & write tutorials for it.
Once you've followed the guide, you can create & run app easily. but there is no mention of publishing in play store officially as of now. wait for some time, they'll tell you soon.
The official documentation has been updated. Look here:
http://facebook.github.io/react-native/docs/signed-apk-android.html#content
As Fackbook hasn't released formal Android deploy method, Try Microsoft Code push to deploy your Android project.
I wrote a tool with some of my colleagues to help setup React Native for deployment. It sets up Fastlane with multiple environments and centralizes the multiple configurations files.
It consists of multiple generators but the ones you will be interested most with are rn-toolbox:fastlane and rn-toolbox:assets (you will need the icons to publish).
We summarised the contents here and you can find the tool on npm
You will still need an Apple Developer account and Android Developer account but this should help you getting to prod quickly.