Skip to content

Commit 555d295

Browse files
authored
Merge pull request #25 from thecodingmachine/docs/android-signed-apk
Documentation for signed apk with fasltane
2 parents e592926 + 620b27a commit 555d295

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

docs/beta builds.md

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,66 @@ You can remove the `deploy lane` to avoid some mistakes, and replace the `beta`
244244
```
245245
desc "Submit a new Beta Build to Play Store"
246246
lane :beta do
247+
store_password = prompt(text: "Signing Store Password: ", secure_text: true)
248+
key_password = prompt(text: "Alias Key Password: ", secure_text: true)
249+
releaseFilePath = File.join(Dir.pwd, "..", "my-release-key.keystore")
250+
gradle(task: 'clean')
247251
gradle(
248252
task: 'assemble',
249-
build_type: 'Release'
253+
build_type: 'Release',
254+
print_command: false,
255+
properties: {
256+
"android.injected.signing.store.file" => releaseFilePath,
257+
"android.injected.signing.store.password" => store_password,
258+
"android.injected.signing.key.alias" => "my-key-alias",
259+
"android.injected.signing.key.password" => key_password,
260+
}
250261
)
251262
upload_to_play_store(
252-
track: 'beta'
263+
track: 'internal'
253264
)
254265
```
255266

267+
As you can see, we need to sign our APK with a signing key.
268+
Don't worry, we will generate it in a moment, let's just explain what the lane do.
269+
270+
First, script ask the user two values : signing store and alias key passwords, with the [`prompt`](https://docs.fastlane.tools/actions/prompt/) fastlane plugin.
271+
Asking the user those passwords ensure that no secret keys are stored into your app.
272+
Then, this lane clean your project, assemble the application, automatically injecting signing configuration at runtime, before uploading it in the Google Play Store.
273+
Upload is made `internaly`, that means only internal testers will be allowed to download the app. You can learn more about different test types [here](https://support.google.com/googleplay/android-developer/answer/3131213).
274+
275+
276+
#### Generating a signing key
277+
278+
[Official documentation](https://facebook.github.io/react-native/docs/signed-apk-android#generating-a-signing-key) well explained how to generate a signing key.
279+
280+
You simply need to run the following :
281+
```bash
282+
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
283+
```
284+
This command prompts you for passwords for the keystore and key and for the Distinguished Name fields for your key.
285+
It then generates the keystore as a file called `my-release-key.keystore`
286+
287+
Note: Remember to keep your keystore file private and never commit it to version control.
288+
289+
Copy the generated `my-release-key.keystore` file into the root of `android` folder.
290+
291+
You're now good to build and deploy !
292+
256293

257294
### Creating a beta build
258295

296+
:warning: The first time you deploy your application, you MUST upload it into Google Play Console `manually`.
297+
Google don't allow to use theirs APIs for the first upload.
298+
To do this, comment the three last lines of the `Fastfile`
299+
```
300+
#upload_to_play_store(
301+
# track: 'internal'
302+
# )
303+
```
304+
or create a new lane without thoses lines.
305+
306+
259307
Creating a beta build and uploading it on Google Play is now really easy.
260308
Just type the following:
261309

@@ -264,11 +312,6 @@ $ cd my-project/android
264312
$ fastlane beta
265313
```
266314

267-
If you have a `Permission denied` issue, please run:
268-
```
269-
$ chmod a+x /my-project/android/gradlew
270-
```
271-
272315

273316
## Troubleshooting
274317

@@ -280,6 +323,12 @@ You can stop the process and retry again with `sudo fastlane init`, however you
280323
$ sudo chown <your-user> <files>
281324
```
282325

326+
### Permission denied running android beta lane
327+
328+
If you have a `Permission denied` issue on an android beta build, please run:
329+
```
330+
$ chmod a+x /my-project/android/gradlew
331+
```
283332

284333
### Fastlane init failed
285334
```
@@ -291,4 +340,8 @@ You can either retry, or fallback to manual setup which will create a basic Fast
291340
Would you like to fallback to a manual Fastfile? (y/n)
292341
```
293342
Answer `n`, and retry previous steps with a correct Apple ID and password.
294-
Make sure you are connected to internet.
343+
Make sure you are connected to internet.
344+
345+
346+
---
347+
If you need more informations, don't hesitate to read the [fastlane documentation](https://docs.fastlane.tools/)

0 commit comments

Comments
 (0)