Skip to content
Matthew Hager edited this page Mar 27, 2015 · 2 revisions

Developing on a Device

Installation

Run cordova run android in your project's cordova directory which will run it on the android device plugged into your computer. If there isn't one, it will boot up the simulator

Debugging

To interact with the Javascript part of the app, in chrome go to chrome://inspect and inspect your app.

To view the device logs run adb logcat in your terminal. This log is pretty verbose so you can filter it out to a specific activity to clean it up. See this SO answer for how to do that. Something like this should be a good start: adb logcat CordovaActivity:V CordovaWebView:V CordovaLog:V YourAppName:V \*:S

This log is most useful when a plugin is not working properly as it will log errors you otherwise wouldn't see that come from native parts of the application.

Facebook Login

Using the phonegap facebook plugin you need to do a few extra steps to get it working properly on Android.

You need to setup a facebook app and then go to it's settings and add the Android platform. Enter the package name and class name(app name). You will need to fill in the Keyhash section as well. Follow the "Generating a keystore" steps below to generate one.

generating a Key Hash

  1. cd ~/.android
  2. keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
  3. When it prompts you for a password, type android and hit Enter

Copy the value printed in the terminal that ends with an “=” and paste it in the Key Hash field in Facebook. Then click the Save Changes button.

[original source](http://stackoverflow.com/a/12577997/1720355}

Releasing Apps

Signing you app

You need to sign the apps with your computer before you can release them. Run this command to generate a release keystore for the project:

keytool -genkey -v -keystore appname.keystore -alias appname -keyalg RSA -keysize 2048 -validity 10000

You will then need to sign the apk with the newly generated keystore.

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore keys/appname.keystore cordova/platforms/android/ant-build/AppName-release-unsigned.apk appname

Finally you need to run the zipalign command to generate the final apk

zipalign -v 4 cordova/platforms/android/ant-build/AppName-release-unsigned.apk cordova/platforms/android/ant-build/AppName.apk

Remembering those commands is hard. I have a script you can add to apps that you can run to generate releases. The gist is here. Replace out the references to eventassist and throw it in your project to make your life easier!

References http://developer.android.com/tools/publishing/app-signing.html http://stackoverflow.com/a/3804645/1720355

App Icon

The path to the final file is within the android folder of the cordova project. In our ember-cli apps, this will be cordova/android/

The designer should name the files icon-32x32.png. The developer will rename each to icon.png when put in the correct folder. Alpha allowed.

  • 36x36 - found in res/drawable-ldpi
  • 48x48 - found in res/drawable-mdpi
  • 72x72 - found in res/drawable-hdpi
  • 96x96 - found in res/drawable-xhdpi

Splashscreen

The files should be named screen-32x32.png. The developer will rename each to screen.png when put in the correct folder.

Portrait

  • 200x320 - found in res/drawable-port-ldpi
  • 320x480 - found in res/drawable-port-mdpi
  • 480x800 - found in res/drawable-port-hdpi
  • 720x1280 - found in res/drawable-port-xhdpi

Landscape

  • 320x200 - found in res/drawable-land-ldpi
  • 480x320 - found in res/drawable-land-mdpi
  • 800x480 - found in res/drawable-land-hdpi
  • 1280x720 - found in res/drawable-land-xhdpi

Play Store

JPEG or 24-bit PNG (no alpha). Min length for any side: 320px. Max length for any side: 3840px. At least 2 screenshots are required overall. Max 8 screenshots per type. Types are phone, 7in tablet and 10in tablet.

  • 512x512 High res icon (alpha allowed)
  • 1024x500 Feature graphic (no alpha)
  • 180x120 Promo graphic (no alpha)

References http://cordova.apache.org/docs/en/3.5.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens