>> Getting the app ready for publication
Copy the project folder on your hard drive and open it in the Android Studio.
For a start, we need to refactor the project in order to a get unique package ID.
By default, package ID is set as pgdating.pilotgroup.datingpro. In order to change the first and the second parts (pgdating and pilotgroup), open the menu File -> Project structure, choose the module datingpro.application, go to the tab Flavors -> find Application ID field -- and change it according to your needs.
Now, we perform the refactoring. In the module datingpro.application search for MainActivity.java, find the following line:
First, refactor pgdating (e.g. to datingtest), then pilotgroup (e.g. to companytest)
Now we have the new package ID:
The change may not be applied throughout the code. To check, use search and replace pgdating.pilotgroup with the name you want to use (in this example it is datingtest.companytest).
>> Adjusting the configuration file
Find the config.xml file in the application module.
application_name with the name that will be displayed under the app icon on the Android devices. Likewise, change
api_url by indicating the address of your dating site with '/api/' at the end (e.g. http://sitename.com/api/). For the
site_url use your site's address (e.g. http://sitename.com).
The rest of the settings will be configured along the way.
>> Signing the app with the key from the keystore
First, let's create a keystore with a key:
When in SDK, find keytool and execute the following command:
keytool -genkey -keystore mykeys.keystore -storepass spassword -alias mykey1 -keypass kpassword1 -keyalg RSA -keysize 2048 -validity 10000
where mykeys.keystore is the name of the future keystore file,
spassword -- the password of the said keystore,
mykey1 -- the future key of the application,
kpassword1 -- password for the key.
After you've created the keystore, you need to sing the app. In Android Studio open File -> Project structure -> datingpro.application module -> find the Signing tab and insert the created data here.
>> Getting API keys (setting up Google Analytics, sign in, Google Maps)
Create a project in the Google API Console by following this link: https://developers.google.com/mobile/add?platform=android.
In the window that appears, indicate the project name (it will appear in the Google Play Developer Console) and enter the package name (in our example it is datingtest.companytest.datingpro), then click Next.
In the new window that opens, set up the Google Sign-In. Here we need to paste the Android Signing Certificate SHA-1 that we got from the keystore that we created. Click Confirm.
Now, open the 'Analytics' tab. Complete all fields and activate it. Copy the Analytics tracking ID. Go to Android Studio, open the config.xml file and add the tracking ID to 'trackerId'.
Back in the browser, click Generate configuration files -> Download google-services.json. Copy this file into the datingpro.application folder.
Open the Google API Console (https://console.developers.google.com/?hl=EN), choose your project and go to the Credentials section. Find 'Android client for [our application]', copy the Client ID, and insert the ID into the config.xml file for
Also, in the API keys, copy the Android key and add it to the config.xml file as
In the Google Console, go to the Library tab and enable the following APIs:
Google Play Developer API (required for the In-app Billing),
Google Maps Android API and Google Places API for Android (required for the Google Maps).
Go to the Firebase console: https://console.firebase.google.com/?hl=en
Click 'Import Google Project' and choose your project. Click the cogwheel icon in the left menu, find and download the 'google-services.json'. Add this file into the datingpro.application folder overwriting the existing file.
>> Setting up the In-app Billing feature
In the Google Play Developer Console, create an account for your application. Use the packageId you have created previously (e.g. datingtest.companytest.datingpro).
Let's create products for the app: In-app products.
Indicate the product ID and price. The product should be Managed (not Subscription).
In the control panel of your dating site, we need to set up the keys: Modules -> Mobile -> In-app Billing settings -> fill in:
Copy the API key from the Google API Console -> Credentials -> find 'Server key'.
In the Google Console, in the list of OAuth 2.0 client IDs find 'Web client (auto created by Google Services)' -- we will need the one that is not for Firebase (Restrictions are not filled in). There, copy the Client ID and Client secret and insert them into corresponding fields in the control panel of the site. Click Save and you will see the 'Refresh tokens' link. Follow the link. Authorization may be required, use the Google account where you?ve created the project. If everything has been done right, the dating site will receive the tokens which will validate the in-app purchases.
In the site's control panel, go to Modules -> Mobile -> In-app Billing -> Purchases and add the products we have created in the Google Play Developer Console: copy the 'Product SKU' (=Product Id), set up the 'Product name' that will be displayed in the app, and add the 'Product price' (this amount will be added to user's internal account during the purchase).
Now, go to the Google Play Developer Console -> Settings -> API Access, find your project and click Link.
In the 'Service accounts' list, find the account that looks like XXXXXXXXXXXXemail@example.com, click Grant access next to it, and select the View financial reports checkbox only.
Get the base64EncodedPublicKey in the Google Play Developer Console -> Services & APIs copy License key and insert it into the config.xml file in the field base64EncodedPublicKey.
>> Setting up the Facebook login
Follow the link https://developers.facebook.com/quickstarts/?platform=android
Click Create App ID and insert the name and email address.
Go to Settings and click Add platform -- choose 'Android'. Use the 'Quick start' button for the step-by-step setup guide. You will be asked to indicate the 'Package Name' and 'Class Name' (in our example they are datingtest.companytest.datingpro and datingtest.companytest.datingpro.application.MainActivity accordingly). You will also need to add the 'Key Hash' (follow the guide that you will find on the page).
Next, find the 'Application Id' for our app and copy it into the config.xml in the field
>> Changing the color scheme of the app (reskin)
The app colors are located in the application module resources: values/colors.xml
Main colors are:
main_color_red and main_color_red_dk (headers, background color, buttons and etc.), gray_dk -- main menu background color, white -- font color (in different menus and colored buttons). For certain elements, colors should be indicated separately.
>> Generating the APK file
In the Android Studio, open the Build menu -> Generate Signed APK. In the pop-up window insert the path to the keystore, keystore password, alias (the app key that we've generated along with the keystore), and the key password. Click Next and choose 'Build Type' -- release, Flavors -- production. Finish.
APK is ready, and you can upload it in the Google Play Developer Console.