0

I would like someone to help me verify what I've done to build a simple mobile app using Sencha Touch and Sencha Cmd.

I've been trying to build an Android app for awhile and I cannot get it run on Android 4.0 emulator or phone, and no luck at all.

This is what I've done.

Step 1: Create a new application

Sencha generate app MyTouch22 ../projects/MyTouch22

This step automatically creates all the necessary folders and files to start your app. It also generated the default Main.js (the main view).

Step 2: Modify the packaging file (packager.json) to comply with Android 4.0 (level 14) as shown below.

{
/**
 * @cfg  applicationName
 * @required
 * This is the name of your application, which is displayed on the device when the app is installed. On IOS, this should match
 * the name of your application in the Apple Provisioning Portal.
 */
"applicationName":"My Touch22",

/**
 * @cfg  applicationId
 * This is the name namespace for your application. On IOS, this should match the name of your application in the Apple Provisioning Portal.
 */
"applicationId":"com.test.mytouch22",

/**
 * @cfg  versionString
 * @required
 * This is the version of your application.
 */
"versionString":"1.0",

/**
 * @cfg  versionCode
 * @required
 * This is the integer version code of your application, or you can refer to it as a build number. Used only for Android builds.
 */
"versionCode":"1",

/**
 * @cfg  icon
 * For iOS, please refer to their documentation about icon sizes:
 * https://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html
 *
 * For Android, please refer to the Google Launcher icons guide:
 * http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
 * iOS uses 57, 72, 114 and 144; Android uses 36, 48 and 72; if you package for Android you can ignore iOS icons and vice verca
 */
"icon": {
    "36":"resources/icons/Icon_Android36.png",
    "48":"resources/icons/Icon_Android48.png",
    "57":"resources/icons/Icon.png",
    "72":"resources/icons/Icon~ipad.png",
    "114":"resources/icons/Icon@2x.png",
    "144":"resources/icons/Icon~ipad@2x.png"
},

/**
 * @cfg  inputPath
 * @required
 * This is location of your Sencha Touch 2 application, relative to this configuration file.
 */
"inputPath":"./",

/**
 * @cfg  outputPath
 * @required
 * This is where the built application file with be saved. Make sure that output path is not in your input path, you may get into endless recursive copying 
 */
"outputPath":"c:\\Apps\\build\\",

/**
 * @cfg  configuration
 * @required
 * This is configuration for your application. `Debug` should always be used unless you are submitting your app to an online
 * store - in which case `Release` should be specified.
 */
"configuration":"Debug",

/**
 * @cfg  platform
 * @required
 * This is the platform where you will be running your application. Available options are:
 *  - iOSSimulator
 *  - iOS
 *  - Android
 *  - AndroidEmulator
 */
"platform":"AndroidEmulator",


/**
 * @cfg  certificatePath
 * This is the location of your certificate.
 * This is required when you are developing for Android or you are developing on Windows.
 */ 
"certificatePath": "C:\\Sencha Architect\\keystore\\test-mytouch22.keystore",


/**
 * @cfg  sdkPath
 * This is the path to the Android SDK, if you are developing an Android application.
 */
"sdkPath": "C:\\Android Development\\adt-bundle-windows-x86_64-20130219\\sdk",  

/**
 * @cfg  androidAPILevel
 * This is android API level, the version of Android SDK to use, you can read more about it here: http://developer.android.com/guide/appendix/api-levels.html.
 * Be sure to install corresponding platform API in android SDK manager (android_sdk/tools/android)
 */
"androidAPILevel":"14",

    /**
 * @cfg {Array[String]} permissions
 * Array of permissions that is used by an application (Android only) 
 * Full list of permissions for Android application can be found here: http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_CHECKIN_PROPERTIES
 */
"permissions":[
        "INTERNET"
    ],

/**
 * @cfg {Array[String]} orientations
 * @required
 * This is orientations that this application can run.
 */
"orientations": [
    "portrait",
    "landscapeLeft",
    "landscapeRight",
    "portraitUpsideDown"
]
}

Step 3: build app to an APK file

sencha app package build packager_android.json

Step 4: Run my android 4.0 emulator

android -avd Android_4_Phone

Step 5: Install APK file into the emulator

adb install MyTouch22.apk

By following the steps I mentioned above, I get stuck on the loading screen. When I re-did the whole process for Android 3.0 (level 11), and using Android emulator, it works file. However, when I deploy the working version APK file (Android 3.0) into Android 4.0 emulator, I got the same problem at the loading page.

The tools I'm using are Sencha Touch 2.2, and Sencha Cmd 3.1.1.274.

Documentation / Source:

  1. http://docs.sencha.com/touch/2.2.0/#!/guide/native_packaging
  2. http://docs.sencha.com/touch/2.2.0/#!/guide/command_app
donny
  • 333
  • 4
  • 9
  • I aways use phonegap to compile to android and never had problem. You already tried? You also can download the sdk for android and see the debug (console and msg javascripts works), is very nice to debug. – Scoup May 10 '13 at 20:09
  • change API level to 7 .. try command `sencha app build native` – Harikrishnan May 11 '13 at 13:45
  • Is it stuck at the initial white screen? I am having the same problem and this happens only with Android 4.0. Not sure why.. BTW, just try changing the API level to 15 and see what happens.. Please post us back if you see any progress.. – GenieWanted May 12 '13 at 03:35
  • @Harikrishnan `sencha app build native` only build the code and you can run in on your web browser, and that part works using API level 14. I need to need to **package the code to deploy the code to the Android emulator and mobile phone**, and this is when the process is falling a part. – donny May 13 '13 at 15:00
  • @donny you are wrong. `sencha app build native` build native code for Android,iPhone,Blackberry. I'm using this. – Harikrishnan May 13 '13 at 17:33
  • @Harikrishnan If you have a moment, please share your step by step process in deploying the android app. I tried your solutions but it does not generate any APK file. I still have to run `sencha app package` after the build cmd. – donny May 14 '13 at 14:54

1 Answers1

1

I suggest you to make a test app with the following steps, If you are getting error on any step, just paste me the error.

1)`sencha generate app Appname ../Appname`
2)open ../Appname and do ur code..make it 100% working on browser
3)open packager.json and fill the necessary fields..the comment shows how to fill it
4)change API level to 7 in it.
5)install android sdk in ur computer and assign it to `sdkPath` variable
6)cd to app directory (Appname)
7)compass compile resources/saas
(Here you have to install ruby if its not installed, just search with the error in google you will get solution)
8)then `sencha app build native`

it will deploy apk file to Appname/build/Appname/native

Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
  • Thank you for the step-by-step instructions. These helps a lot. I got it working now. I just want to make one small correction from the instruction above, on step #7 `compass compile resources/sass` – donny May 15 '13 at 19:52
  • I dint get it..can u explain? (By the way compass compile will already executing while build..its not needed..I have given that step to show you the exact errors if ruby/gem not installed). – Harikrishnan May 16 '13 at 03:14
  • Ok. However, it helped me to figure out my error too. Apparently, even though Sencha Cmd 3.1.1 suppose to come with Ruby 1.9.xx, when I executed the build process it failed to run ruby automatically. – donny May 16 '13 at 13:31
  • @Harikrishan: I have a doubt, I have successfully generated android apk from sencha touch project , unfortunately when i ran that app in android device or emulator , only the splash image is displayed , nothing happens, is server is needed to run, so that the app can fetch contents from sencha touch project? , because i gone through some samples in sencha touch they used xampp as local server for running the broswer. – Sankar Ganesh PMP Sep 19 '14 at 10:23
  • If you are not using back end webservice no webserver is needed to run sencha app. It's just javascript. Try making apk from any sample project and run it in mobile. – Harikrishnan Sep 19 '14 at 11:56
  • @Harikrishnan: I got that sencha touch project from some blog not sure where am i download, for my learning i downloaded that and my desire is to generate the apk from sencha touch , that i got now but only splash screen is showing up , so i planning to debug that code, before that i had this doubt,Could please tell me how can i find whether that sencha touch project using back end web service or not? – Sankar Ganesh PMP Sep 19 '14 at 12:26
  • For webservice call usually these methods are used `Ext.data.Request`, `Ext.data.JsonP`, `Ext.Ajax.request` – Harikrishnan Sep 19 '14 at 12:41
  • Best way to check is take sencha project in chrome and take console look for errors/ Network requests.. – Harikrishnan Sep 19 '14 at 12:42
  • I think i have to check app.js file right for these Ext.data.Request, Ext.data.JsonP, Ext.Ajax.request , if am wrong please convey me where to check for these , Meanwhile in my app.js , they have called something like this Ext.data.proxy.LocalStorage , where i can find meaning about these complete api – Sankar Ganesh PMP Sep 19 '14 at 12:46