Saturday, March 16, 2019

Android开发笔记: 3.8 Commercialize


3.8 Commercialize

3.8.1 App and Google Play setting

To be able to upload bundle instead of APK, need to opt in Goole App Sign, with your keystore file my_keystore.jks and your key as $key, run:
java -jar pepk.jar --keystore=my_keystore.jks --alias=my_android --output=my_key –encryptionkey=$key => will create my_key file, which needs to be uploaded to GooglePlay console.
With Android Studio to create the keystore and key and build, it will generate an apk as: app/build/outputs/apk/app-release-unaligned.apk. This apk still cannot be uploaded to app store as it needs to be zip-aligned. app/app-release.apk is the one can be uploaded. Refer this, ProGuard mapping file app/build/outputs/mapping/release/mapping.txt can be uploaded for deobfuscate crash stack traces.
If following the instruction either 'Open Module Setting'/F4 or click menu=>Build=>Edit Build Types, click 'signing' tab, fill all info, which will be automatically copied to app build.gradle file. To make it get password either from ENV, modify the gradle file:
storePassword System.getenv("KSTOREPWD")
keyPassword System.getenv("KEYPWD")
Or if build from command line(which I haven't figured out how):
storePassword System.console().readLine("\nKeystore password: ")
keyPassword System.console().readLine("\nKey password: ")
Each time update the app, make sure modify build.gradle(Module: app) to update the versionCode,
 optionally update versionName. Refer this for more about version code. In a project, it
 is set in AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="29"
 android:versionName="1.2.9" package="some_corp.com">
Refer this SO for detail of the CERT.RSA and CERT.SF file under META-INF folder. 


3.8.2 Webserve

For some app, may need to provide internet service such as public shared files/resource,
dbase support for user autherize. Google Drive, Box.net, Dropbox may all provide cloud storage,
but mostly can not be accessed directly by apps. For example, if the app needs to pull in a 
configuration file, with Google Drive even shared through a link, the link is not directly to
the file, but a view of the file provide by Google. I found OpenShift from this post, which is
backed by Redhat with Node.js host, and is free. Code there is maintained with git, which needs a pub key: ssh-keygen -t rsa. Upto 3 free
Apps can be maintained through web console or command line client tools rhc. For install rhc,
just apt-get install ruby-full, no need of rubygems, then sudo gem install rhc. If see Error
installing rhc: net-ssh requires Ruby version >= 2.0, follow this SO to upgrade ruby:
 ppa:brightbox/ruby-ng and installed ruby2.4. And for me it is installed as:
 /var/lib/gems/1.9.1/gems/rhc-1.38.4/bin/rhc. Openshift was re-designed one years ago, and use
 oc command line utility. It needs Openssl 1.0.1(Ubuntu16.04/xenial has 1.0.2g), following au 
 won’t fix the lib problem, tried to download openssl 1.0.1/ and build it. Since I need the shared
 lib, have to do ./config shared before make it. And make install will copy the so files to
 /usr/local/ssl/lib. But that doesn’t work either. Refer to issues/21061. To build oc:
 git clone https://github.com/openshift/origin Start from openshift debian-ubuntu.html.
I installed http://www.nodeclipse.org/updates/ for developing node.js within Eclipse.
<app_name> to get tar of all packages and logs. Seems Node.js' http won't accept txt as
Content-type. I updated app.js to support downloading the txt file. For dbase, refer 5.3.
PostgreSQL is great, but for some project, MonGoDB(refer this) is more simple to use.
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
column Field
Table Join Embedded Documents
Primary Key Primary Key (Default key _id provided by mongodb itself)
Database Server and Client
Mysqld/Oracle mongod
mysql/sqlplus mongo
When creating collection, refer to this SO, try to avoid name of database object method such as 'stats', 'group'.
This github is a working sample with node+express+mongodb
URL $OPENSHIFT_MONGODB_DB_URL: mongodb://user:pw@$OPENSHIFT_MONGODB_DB_HOST:$OPENSHIFT_MONGODB_DB_PORT/
I'm using node.js code from this SO for query user's IP:
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress;
clustrmaps provides a real-time map of visitors from around the world. 
 In order to tracking user IP, may need node.js proxy code to forward the request to another
 html page with in openshift domain, such as the index.htm. Refer to proxy SO and redirect SO.
 It won’t work as the js is expected to be run by the visitor device’s web browser. Similar
 widgets are mentioned here, which are target to portal website or blog.
App may need to access cloud storage for update info, resource. Need directly access with a
 link, which is not supported by most cloud service such as Google Drive, Dropbox, Box.net. 
But some mentioned tricks to achieve that, in short in this trick we are simply replacing 
“www.dropbox.com” with “dl.dropboxusercontent.com”. Change the query “?dl=1” can download the
file, but it still is not direct link.

Refer this(a little old) and this for host video stream service cost.

0 Comments:

Post a Comment