Showing posts with label APK. Show all posts
Showing posts with label APK. Show all posts

Android: using zipalign command line tool to align APK for Prod Deployment

Aligning APK with Zipalign command line tool



usage:

zipalign : you can find that tool in your Android/sdk/build-tools/23.0.3/ folder

-f : replaces existing file

-v : verbose output

4 : required by Android alignment bytes

input apk : already signed APK as it comes out from Android Studio

output APK : file you will upload to Google Play Developer Console



> 23.0.3 $ pwd
/Users/ukilucas/Library/Android/sdk/build-tools/23.0.3



> 23.0.3 $ 
./zipalign -f -v 4 ~/CyberFit-release-23.apk ~/CyberFit-release-23_aligned.apk


As an Amazon Associate I earn from qualifying purchases.

Android: using zipalign command line tool to align APK for Prod Deployment

Aligning APK with Zipalign command line tool



usage:

zipalign : you can find that tool in your Android/sdk/build-tools/23.0.3/ folder

-f : replaces existing file

-v : verbose output

4 : required by Android alignment bytes

input apk : already signed APK as it comes out from Android Studio

output APK : file you will upload to Google Play Developer Console



> 23.0.3 $ pwd
/Users/ukilucas/Library/Android/sdk/build-tools/23.0.3



> 23.0.3 $ 
./zipalign -f -v 4 ~/CyberFit-release-23.apk ~/CyberFit-release-23_aligned.apk


As an Amazon Associate I earn from qualifying purchases.

Running Android APK in the Mac Chrome browser

I have had this dilemma for a while now "Android or JavaFX" for creating UI (user interface) applications. If I create Android, then great, but that limits me to phones/tablets, what about computers?

Also, when developing Android apps your computer/laptop needs either an emulator, or you have to use a phone/tablet to test run the apps.

Emulator with it's heavy footprint is not really a solution, unless you are actively developing, so I was looking for easier way to run my apps at any time.

I have come across this ARChon solution when it first came out and decided to give it a go.

First I downloaded their extension and the demo game (2048), copied it to a ARChon folder in my Applications and unzipped both:

in Chrome browser I went to Chrome > Preferences > Extensions


and installed both and run (Launch on the game) it successfully without a problem.

Then I DUPLICATED to the folder of the GAME and replaced their APK with mine, I adjusted the manifest.json with some OBVIOUS changes, and added this folder to Chrome Extensions again, I was able to run it without any problems.



{
  "app": {
    "background": {
      "page": "app_main.html"
    }
  },
  "arc_metadata": {
    "apkList": [
      "MyApp-UKI-SNAPSHOT.apk"    ],
    "enableExternalDirectory": false,
    "formFactor": "phone",
    "name": "MyApp-UKI",    "orientation": "landscape",    "packageName": "com.mycompany.android.myapp",    "useGoogleContactsSyncAdapter": false,
    "usePlayServices": [
      "gcm"
    ]
  },
  "default_locale": "en",
  "icons": {
    "16": "icon.png",
    "128": "icon.png"
  },







As an Amazon Associate I earn from qualifying purchases.

Running Android APK in the Mac Chrome browser

I have had this dilemma for a while now "Android or JavaFX" for creating UI (user interface) applications. If I create Android, then great, but that limits me to phones/tablets, what about computers?

Also, when developing Android apps your computer/laptop needs either an emulator, or you have to use a phone/tablet to test run the apps.

Emulator with it's heavy footprint is not really a solution, unless you are actively developing, so I was looking for easier way to run my apps at any time.

I have come across this ARChon solution when it first came out and decided to give it a go.

First I downloaded their extension and the demo game (2048), copied it to a ARChon folder in my Applications and unzipped both:

in Chrome browser I went to Chrome > Preferences > Extensions


and installed both and run (Launch on the game) it successfully without a problem.

Then I DUPLICATED to the folder of the GAME and replaced their APK with mine, I adjusted the manifest.json with some OBVIOUS changes, and added this folder to Chrome Extensions again, I was able to run it without any problems.



{
  "app": {
    "background": {
      "page": "app_main.html"
    }
  },
  "arc_metadata": {
    "apkList": [
      "MyApp-UKI-SNAPSHOT.apk"    ],
    "enableExternalDirectory": false,
    "formFactor": "phone",
    "name": "MyApp-UKI",    "orientation": "landscape",    "packageName": "com.mycompany.android.myapp",    "useGoogleContactsSyncAdapter": false,
    "usePlayServices": [
      "gcm"
    ]
  },
  "default_locale": "en",
  "icons": {
    "16": "icon.png",
    "128": "icon.png"
  },







As an Amazon Associate I earn from qualifying purchases.

Maven: installing apk, or arr, or jar in .m2

Sometimes you get a built artifact (apk, arr, jar) and instead of keeping it in your Downloads, or com up with a nice folder structure, you can simply put it in your Maven .m2 repository, that what it is designed for.


$ mvn install:install-file -Dpackaging=apk -DgroupId=com. mycompany.android -DartifactId= SomeApp -Dversion=1.4.42.0 -Dfile=/Users/uki/Downloads/SomeApp-1.4.42.0.apk

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---

[INFO] Installing /Users/uki/Downloads/SomeApp-1.4.42.0.apk to /Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.apk

[INFO] Installing .../Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------



As an Amazon Associate I earn from qualifying purchases.

Maven: installing apk, or arr, or jar in .m2

Sometimes you get a built artifact (apk, arr, jar) and instead of keeping it in your Downloads, or com up with a nice folder structure, you can simply put it in your Maven .m2 repository, that what it is designed for.


$ mvn install:install-file -Dpackaging=apk -DgroupId=com. mycompany.android -DartifactId= SomeApp -Dversion=1.4.42.0 -Dfile=/Users/uki/Downloads/SomeApp-1.4.42.0.apk

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---

[INFO] Installing /Users/uki/Downloads/SomeApp-1.4.42.0.apk to /Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.apk

[INFO] Installing .../Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------



As an Amazon Associate I earn from qualifying purchases.

Android: ADB install apk

In this tutorial you will learn frequently used Terminal commands (from your computer) to manage APKs on your Android device.



As an Amazon Associate I earn from qualifying purchases.

Android: ADB install apk

In this tutorial you will learn frequently used Terminal commands (from your computer) to manage APKs on your Android device.


Search what APKs you have installed on your device

$ adb shell 'pm list packages -f' | grep /data/app/com.chicago
package:/data/app/com.chicagoandroid.cit299.week7.bookshelf-1.apk...
package:/data/app/com.chicagoandroid.cit299.naturesounds.appnaturesounds-1.apk...
package:/data/app/com.chicagoandroid.cit299.simplecamera-2.apk...

Uninstall APK by the package you found above.

$ adb uninstall com.your_package
$ adb uninstall com.chicagoandroid.cit299.week7.bookshelf

Success

Install APK 

in this example I am using created my Maven (mvn install), but you can use APK in the auto-generated build folder e.g.:

CIT299/appNatureSounds/build/outputs/apk/appNatureSounds-debug-unaligned.apk

$ adb install -r ~/.m2/repository/com/xyz.app_name/1.0-SNAPSHOT/app_name-x.y-SNAPSHOT.apk



Start the APK (you need to know the Activity name)


$ adb shell 'am start -n "com.your_package/com.your_packag.activity.YourMainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER'






As an Amazon Associate I earn from qualifying purchases.

Icon.png: failure while uploading to Google Play Market


After upload of APK to Google Market this is exception that Google returns:


The file is invalid: W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) ERROR getting 'android:icon' attribute: attribute is not a string value


The fix was to put to each res/drawable[..] folder you have a copy of the icon.png

hdpi - 72x72
ldpi - 36x36
mdpi - 48x48
xhdpi- 96x96


As an Amazon Associate I earn from qualifying purchases.

Icon.png: failure while uploading to Google Play Market


After upload of APK to Google Market this is exception that Google returns:


The file is invalid: W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) W/ResourceType( 2338): Failure getting entry for 0x7f0200cb (t=1 e=203) in package 0 (error -75) ERROR getting 'android:icon' attribute: attribute is not a string value


The fix was to put to each res/drawable[..] folder you have a copy of the icon.png

hdpi - 72x72
ldpi - 36x36
mdpi - 48x48
xhdpi- 96x96


As an Amazon Associate I earn from qualifying purchases.

apt quotation..