Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit e9ea66e

Browse files
committed
Merge pull request #242 from NativeScript/cankov/publishing
Add articles about App Store and Play Store publishing
2 parents 905c5f5 + 6633bb8 commit e9ea66e

File tree

3 files changed

+529
-37
lines changed

3 files changed

+529
-37
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
title: Publishing for Android
3+
description: Learn how to publish your app in the Play Store for Android users.
4+
position: 11
5+
slug: publishing-android-apps
6+
---
7+
8+
# Publishing a NativeScript Android App in Google Play
9+
10+
0. [Overview](#overview)
11+
1. [Creating Android NativeScript App](#creating-android-nativescript-app)
12+
1. [Application Id and Package Name](#application-id-and-package-name)
13+
2. [App Name](#app-name)
14+
3. [App Icons](#app-icons)
15+
2. [Certificates](#certificates)
16+
1. [Debug Certificate](#debug-certificate)
17+
2. [Release Certificate](#release-certificate)
18+
3. [Google Play Developer Console](#google-play-developer-console)
19+
1. [Creating an App](#creating-an-app)
20+
2. [Builds](#builds)
21+
1. [Build Versioning](#build-versioning)
22+
2. [Build Signed Release APK](#build-signed-release-apk)
23+
3. [Submit with the Google Play Developer Console](#submit-with-the-google-play-developer-console)
24+
4. [Submit with Telerik AppManager](#submit-with-telerik-appmanager)
25+
5. [Submission Automation](#submission-automation)
26+
4. [Publish](#publish)
27+
28+
## Overview
29+
You can publish a NativeScript app in *Google Play* the same way [you would release a purely native Android app](http://developer.android.com/tools/publishing/publishing_overview.html).
30+
31+
1. Verify that the Android native project inside your app contains your latest changes and resources by running the following command.
32+
33+
```
34+
tns prepare android
35+
```
36+
2. Make sure that you have a `.keystore` file to sign your app with. For more information, see [How to create a .keystore file](http://developer.android.com/tools/publishing/app-signing.html#signing-manually)?
37+
3. Build your project in release mode by running the following command:
38+
39+
```
40+
tns build android --release --key-store-path <path-to-your-keystore> --key-store-password <your-key-store-password> --key-store-alias <your-alias-name> --key-store-alias-password <your-alias-password>
41+
```
42+
4. Obtain the release `.apk` located at `<app_name>/platforms/android/build/outputs/apk/<app_name>-release.apk`.
43+
5. Publish your Android app by uploading the `.apk` file to the Google Developer Console. For more information, see [How to publish an Android app?](http://developer.android.com/distribute/googleplay/start.html)
44+
45+
## Creating Android NativeScript App
46+
### Application Id and Package Name
47+
Both *Package Name*, and *Application Id*, are unique identifiers, provided by you for your app.
48+
- *Package Name* is used to identify resources such as the `R`.
49+
- *Application Id* is used to identify your app on devices and at the *Google Play*.
50+
51+
In the NativeScript framework both are set to the `nativescript.id` in `package.json`.
52+
The NativeScript CLI build system will set them as the `package` attribute in the generated project in `platforms/android/src/main/AndroidManifest.xml`.
53+
In the `app/App_Resources/Android/AndroidManifest.xml` it will use a placeholder: `package="__PACKAGE__"`. Do **not** modify the `package` attribute there.
54+
55+
> **NOTE:** To edit the *Package Name* and the *Application Id*, modify the `package.json` of your app and set the `nativescript.id` key.
56+
You may need to delete `platforms/android` and rebuild using the CLI command `tns prepare android`.
57+
58+
[Read more about "ApplicationId versus PackageName"](http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename).
59+
60+
### App Name
61+
This is the display name for your app. It is purely cosmetic but highly important. For example, it appears under the app icon.
62+
The value can be stored in the `app/App_Resources/Android/AndroidManifest.xml` file, as an `android:label="<App Name>"` attribute, on the `<application>` element.
63+
64+
You can check more information about [the elements you can define in the `AndroidManifest.xml` here](http://developer.android.com/guide/topics/manifest/application-element.html).
65+
66+
### App Icons
67+
App icons are defined similar to the App Name.
68+
The icon name is defined in the `app/App_Resources/Android/AndroidManifest.xml` file, as an `android:icon="@drawable/icon"` attribute, on the `<application>` element.
69+
70+
The actual .PNG icons stay at the Android resources in `app/App_Resource/Android/<DPI>/icon.png`, DPIs:
71+
72+
| directory | DPI | screen | size |
73+
|-------------------|-----|---------------------------------------|---------------|
74+
| `drawable-ldpi` | 120 | Low density screen | 36px x 36px |
75+
| `drawable-mdpi` | 160 | Medium density screen) | 48px x 48px |
76+
| `drawable-hdpi` | 240 | High density screen) | 72px x 72px |
77+
| `drawable-xhdpi` | 320 | Extra-high density screen | 96px x 96px |
78+
| `drawable-xxhdpi` | 480 | Extra-extra-high density screen | 144px x 144px |
79+
| `drawable-xxxhdpi`| 640 | Extra-extra-extra-high density screen | 192px x 192px |
80+
81+
### Splash Screen
82+
Android has no built in mechanism to provide splash screen image.
83+
[Here is a blog post how to implementat a splash screen in the NativeScript framework.](https://www.nativescript.org/blog/details/splash-screen-for-your-android-applications)
84+
85+
## Certificates
86+
### Debug Certificate
87+
These are automatically generated by the Android SDK tools for you.
88+
89+
In debug mode, you sign your app with a debug certificate.
90+
This certificate has a private key with a known password.
91+
The process is handled by the Android tooling.
92+
93+
You can read more at ["Signing in Debug Mode"](http://developer.android.com/tools/publishing/app-signing.html)
94+
95+
### Release Certificate
96+
The release certificate for Android is created by you, and does not have to be signed by a certificate authority.
97+
It is easier to create a release certificate for Android, than it is for iOS. You should however, be more careful with your certificate.
98+
99+
A few pitfalls are:
100+
- You create the cetificate only once. Should you lose it, you will not be able to publish any updates to your app, because you must always sign all versions of your app with the same key.
101+
- If your certificate expire, you will not be able to renew it. Ensure long validity when creating a new certificate (for 20+ years).
102+
- If a third party obtains your private key, that party could sign and distribute apps that maliciously replace your authentic apps or corrupt them.
103+
104+
You can generate a private key for release certificate using the [keytool](http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html).
105+
```
106+
keytool -genkey -v -keystore <my-release-key>.keystore -alias <alias_name> -keyalg RSA -keysize 2048 -validity 10000
107+
```
108+
109+
This will run an interactive session collecting information about your name, organization, and most importantly - keystore and alias passwords.
110+
111+
## Google Play Developer Console
112+
You will need a developer account and be able to log into the [Google Play Developer Console](https://play.google.com/apps/publish/)
113+
114+
### Creating an App
115+
Go to **All applications** section and click the **+ Add new application** button.
116+
117+
You get prompted to provide app title and you can proceed with the store listings.
118+
You can fill in app description, screenshots and so on.
119+
120+
You can also submit an APK. Read on how to obtain APK from a NativeScript app.
121+
122+
### Builds
123+
#### Build Versioning
124+
We have already explained how the *Application Id* is set in your project,
125+
how icons are added to your app and how you can set display name.
126+
127+
Before the build, you need to set two important things - the *versionCode* and the *android:versionName*.
128+
129+
When a build is uploaded its *versionCode* should be larger than previous builds.
130+
A new build with a higher *versionCode* is considered an upgrade to these with lower *versionCode*.
131+
The *versionCode* is an integer so you should carefully consider a strategy for versioning.
132+
133+
Both values are stored in `app/App_Resources/Android/AndroidManifest.xml`.
134+
135+
You can read more about ["Versioning Your Applications"](http://developer.android.com/tools/publishing/versioning.html).
136+
137+
In the `app/App_Resources/Android/AndroidManifest.xml` the *versionCode* and *versionName* appear as:
138+
```
139+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
140+
package="org.nativescript.name"
141+
android:versionCode="2"
142+
android:versionName="1.1">
143+
...
144+
```
145+
146+
#### Build Signed Release APK
147+
You can perform a full build and produce a signed APK using the NativeScript CLI:
148+
```
149+
tns build android --release --key-store-path <path-to-your-keystore> --key-store-password <your-key-store-password> --key-store-alias <your-alias-name> --key-store-alias-password <your-alias-password> --copy-to <apk-location>.apk
150+
```
151+
You can then use the produced `<apk-location>.apk` for upload at the *Google Play*.
152+
153+
#### Submit with the Google Play Developer Console
154+
To submit your app at the *Google Play Developer Console*:
155+
156+
1. Log into the [Google Play Developer Console](https://play.google.com/apps/publish).
157+
2. Select your application and go to the **APK** section.
158+
3. Choose *Production*, *Beta* or *Alpha* stage and click the **Upload new APK**.
159+
4. Select the APK produced by the CLI.
160+
161+
You can read more about these stages at ["Set up alpha/beta tests"](https://support.google.com/googleplay/android-developer/answer/3131213?hl=en).
162+
163+
Once you upload your APK, it will go through a review.
164+
When approved, you can move it to production to make it available at the *Google Play*.
165+
166+
#### Submit with Telerik AppManager
167+
It is worth mentioning that the NativeScript platform is integrated in the *Telerik Platform*.
168+
And the *Telerik Platform* has everything you need in the cloud, easing the submission process.
169+
This includes managing your distribution certificates and provisioning profiles,
170+
as well as support for cloud builds and *App Store* submission.
171+
172+
Read more about app submission process in the *Telerik Platform* in ['Introduction to Telerik AppManager'](http://docs.telerik.com/platform/appmanager/getting-started/introduction)
173+
174+
#### Submission Automation
175+
Then there are some tools that allow the submission process to be automated - [MIT Licensed one: fastlane](https://github.com/fastlane/fastlane).
176+
You can also hack your own scripts around the [Google Play Developer API](https://developers.google.com/android-publisher/api-ref/edits/apks/upload).
177+
178+
## Publish
179+
Once you successfully upload your APK, and it passes Google review,
180+
you will be able to move your APK to production,
181+
and it will go live at the *Google Play*.

0 commit comments

Comments
 (0)