Friday, June 2, 2017

Generating release version apk file in Oracle Jet

To release your application to users you need to create a release-ready package that users can install and run on their Android-powered devices. The release-ready package contains the same components as the debug APK file — compiled source code, resources, manifest file, and so on — and it is built using the same build tools. However, unlike the debug APK file, the release-ready APK file is signed with your own certificate and it is optimized with the zip align tool.


Package the Android version of your app

In this section:
  • Generate a private key.
  • Refer to that key in a configuration file.
  • Create the package.


Step 1: Generate a private key

To sign your app, create a keystore. A keystore is a binary file that contains a set of private keys. Here's how you create one.
  1. Open a Command Prompt in administrator mode.
  2. In the Command Prompt, change directories to the %JAVA_HOME%\bin folder.
    (For example: C:\Program Files (x86)\Java\jdk1.7.0_55\bin).
  3. In the Command Prompt, run the following command.
    keytool -genkey -v -keystore c:\my-release-key.keystore -alias Ansh
    -keyalg RSA -keysize 2048 -validity 10000
    
    Replace my-release-key.keystore and Ansh with names that make sense to you.
  4. You'll be asked to provide a password and the Distinguished Name fields for your key.
    This series of responses gives you an idea of the kinds of information you'll provide for each prompt. Like in the previous command, respond to each prompt with information that makes sense for your app.
    Enter keystore password: pwd123
    Re-enter new password: pwd123
    What is your first and last name?
    [Unknown]= Anshuman Panda
    What is the name of your organizational unit?
    [Unknown]= ABC
    What is the name of your organization?
    [Unknown]= XYZ
    What is the name of your of your City or Locality?
    [Unknown]= Bangalore
    What is the name of your State or Province?
    [Unknown]= KA
    What is the two-letter country code for this unit?
    [Unknown]= IN
    Is CN=Anshuman Panda, OU=ABC, O=XYZ, L=Bangalore, ST=KA, C=IN correct??
    [no]=  y
    
    
    After you provide this information, output like this appears in the Command Prompt.
    Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA)
    with a validity of 10,000 days for: CN= Anshuman Panda, OU= ABC, O= XYZ,
    L=Bangalore, ST=KA, C=IN
    
    Enter key password for <Ansh>
        (RETURN if same as keystore password):
    
    The Android SDK generates the keystore as a file named my-release-key.keystore and places that file in the C:\ drive. The keystore contains a single key, valid for 10000 days.


Step 2: Refer to the private key in a configuration file


Add the below in buildConfig.json à

{
 "android": {
     "release": {
         "keystore":"c:\\my-release-key.keystore",
         "storePassword":"anshuman",
         "alias":"AnshKey",
         "password":"anshuman",
         "keystoreType":""
       }
   }
}

Step 3: Create the package


grunt build --platform={android|ios} [--buildConfig=path/buildConfig.json]


grunt serve:release --platform=android --buildConfig=buildConfig.json


e.g. grunt serve:release --platform=android --buildConfig=D:/build.json

No comments:

Post a Comment

Push notification in Oracle JET Hybrid application

Below are the main steps involved: First android device sends Sender ID, application ID to GCM/FCM for registration Upon successful reg...