Sencha Touch 2 Native Packaging for Android

准备

打包安卓应用

  1. Prerequisite: Obtain an appropriate Android ready certificate (debug or release) for signing the application
  2. Install Sencha SDK Tools (SenchaSDKTools 2.0).
  3. Create a packaging configuration file to be use with the packager.
  4. Run the packager to create a packaged .apk.

Step 1: Android certification generation

The Android Keytool included in the Android SDK tools is one way of creating certificate for signing Android applications. Below is an example of a Keytool command that generates a private key:

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name
    -keyalg RSA -keysize 2048-validity 10000

Follow the steps on the Android developers guide “Signing Your Applications” for more information about creating certificates and signing applications.

Step 2: 安装 Sencha SDK Tools.

  • Run the Sencha SDK installation: SenchaSDKTools (SenchaSDKTools-2.0.0-Beta)
  • The sencha command that includes the package option will be installed to the specified location during installation (default: Applications/SenchaSDKTools-2.0.0-Beta/command).

Step 3: Create a packaging configuration file to be used with the native packager.

The configuration file has the following format:

{"applicationName":"<AppName>","applicationId":"<AppID>","outputPath":"<AppPackageOutputPath>","iconName":"<AppIconName>","versionString":"<AppVersion>","inputPath":"<PathToWebApp>","configuration":"<Release | Debug>","platform":"<Android | AndroidEmulator>","certificatePath":"<certificatePath>","certificateAlias":"<certificateAlias>","sdkPath":"/android-sdk-mac_86","orientations":["portrait","landscapeLeft","landscapeRight","portraitUpsideDown"],"deviceType":"<Not applicable for Android>"}

A configuration file template can be created by running the following command:

sencha package generate <configTemplate.json>

<configTemplate.json> is the name of the configuration template file.

Note: the <configTemplate.json> path or filename cannot contain any space.

The following parameters are applicable to Android packages:

"applicationName":"<AppName>"

Specifies the name of your application (AppName). The output file will have the name <AppName>.apk.

"applicationId":"<AppID>"

Specifies an ID given to your application. It's suggested that you use a nameSpace for your app, such as com.sencha.Touch2Package.

"outputPath":"<AppPackageOutputPath>"

Specifies the output location of the packaged application <application.apk>.

"iconName":"<AppIconName>"

Specifies the launcher icon file to be used for your application. Refer to the Android Launcher Icons guide for further information on icon file specifications.

"versionString":"<AppVersion>",

Specifies the version of the application.

"webAppPath":"<PathToWebApp>"

Specifies the path of the web application to be packaged.

"configuration":"<Release | Debug>"

Specifies the build type from either Release or Debug.

"platform":"<Android | AndroidEmulator>"

Specifies if the build is for the Android device (Android) or the Android Emulator (AndroidEmulator).

"certificatePath":"<certificatePath>",

Specifies a specific Certificate location for the certificate used for signing your application.

"certificateAlias":"<CertificateAlias>"

Specifies a specific Certificate Alias to use for signing your application.

"orientations":["portrait","landscapeLeft","landscapeRight","portraitUpsideDown"

Optional parameter. Specifies the orientations of the application. Available options: portraitlandscapelandscapeRight, andportraitUpsideDown. If omitted, defaults to all four orientations mode.

"deviceType"

This is not applicable for Android applications. This config parameter is ignored when building an Android application.

Sample debug configuration file
{"applicationName":"SenchaTouch2Package","applicationId":"com.sencha.Touch2Package","iconName":"icon.png","versionString":"1.0","outputPath":"~/Desktop/STBuild-Android","webAppPath":"~/Desktop/www/","configuration":"Debug","platform":"Android","deviceType":"Universal","certificatePath":"~/Desktop/debug.keystore","certificateAlias":"androiddebugkey","sdkPath":"~/Desktop/android-sdk-mac_x86","orientations":["portrait","landscapeLeft","landscapeRight","portraitUpsideDown"]}
Sample release configuration file
{"applicationName":"SenchaTouch2Package","applicationId":"com.sencha.Touch2Package","iconName":"icon.png","versionString":"1.0","outputPath":"~/Desktop/STBuild-Android","webAppPath":"~/Desktop/www/","configuration":"Release","platform":"Android","deviceType":"Universal","certificatePath":"~/Desktop/senchatouch-key.keystore","certificateAlias":"senchatouch","sdkPath":"~/Desktop/android-sdk-mac_x86","orientations":["portrait","landscapeLeft","landscapeRight","portraitUpsideDown"]}

Step 4: Run the packager to create a packaged <application>.apk

Packaging a debug application and run it on an Android Emulator

Prerequisite: The Platform and Configuration setting needs to be set in the config file, for example

platform:AndroidEmulator
configuration:Debug

To package a debug application to run on the Android Emulator, do the following:

  • Start the Android Emulator
  • Issue the following command:

    sencha package run <configFile.json>

The application will start in the already running Android Emulator after successful execution of this command. If Android Emulator is not started before issuing the command, Android Emulator will not start automatically. If package is successful, an .apk is available in the application output location for you to manually test it on an Android Emulator or a device.

More info about Android Emulator can be found on the Android Developer Guide: Using the Android Emulator.

Packaging the application for distribution

To package a signed application to run on the device, issue the following command:

sencha package<configFile.json>

An <AppName.apk> is created in the specified output location. This is the application that you can use to release for distribution.

See Also

  1. Signing Your Applications
  2. Installing the ADT Plugin for Eclipse
  3. Eclipse
  4. Managing Virtual Devices for Android Emulator

Comments

Jaganlal
5th Feb '12
  0  

When i do a debug build for Android platform, i get the following error. ~path/AndroidManifest.xml:10: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon') Any help'll be appreciated. I'm using "iconName":"icon.png" I have icon.png in web application path (note, i tried to give the whole image path, still no use)

baamenabar
8th May '12
  0  

Notice that the example file on some distributions give a relative path to the inputPath parameter, it HAS to be absolute.

also

@Jaganlal: I had the same problem! then realized what the instruction meant... "This is file name of your icon. This should be in the same directory of this configuration file." it HAS to be on the same folder as the < packager.json > config file

gruese
7th Aug '12
  0  

In the last paragraph, the sencha command line is stated as

sencha package <configFile.json>

which does not work (shows usage info in command shell). If I'm not mistaken, this should be changed to

sencha package build <configFile.json>

pavel.stupka
9th Aug '12
  0  

How can I configure Android permissions using this configuration?

CMC
13th Aug '12
  0  

I keep getting this error: -bash: syntax error near unexpected token `newline'. what does this mean?

jop
28th Aug '12
  2  

Sencha Team, please correct in this text the lack of 'build' as stated by gruese.

In any case, I think everything is a little confused concerning sencha command, paths, etc. Still trying to create build in Windows without success.

jop
29th Aug '12
  2  

webAppPath or inputPath?

rain-er
3rd Sep '12
  0  

Successfully created a native apk package. But it does not workl Always the same error message "The webpage at file:///android_asset/index.html might be temporarily down....." Is anybody able to generate native apps for Android?????

ekjyot.kaur
14th Sep '12
  0  

Hi, I am trying to create apk file, but i am getting error " the current working directory is not a recognised sencha sdk or application folder.the specified config file is not available. "

jonathan999
27th Sep '12
  0  

Hi, when executing: sencha package build myConfig.json I am not getting any errors but the apk is not being generated. Is there an output message in the command prompt if the build is successful?

keshav.vohra
14th Oct '12
  0  

how can i set the version code for the app. I am trying to submit an update and its saying that versionCode 1 is alrady in use.

alonsozelek
15th Oct '12
  0  

jonathan999 Hi, when executing: sencha package build myConfig.json I am not getting any errors but the apk is not being generated. Is there an output message in the command prompt if the build is successful?

I HAVE the same problem, you could send my the solution please?

alonsozelek
15th Oct '12
  0  

And my application is not run in Android Emulator.

Help me please!

DougFisher
15th Oct '12
  0  

The Getting Started Video says to use sencha app build native I also noticed that at least in some places you should not use a backslash "\" in the file names, even though you are on windows. Use a forward slash instead "/". Then had to change my path to include the path to javac.exe (set path=%path%;C:\Program Files... Then I noticed that it was using parameter --target android-7 It gave the helpful command to run: android.bat list targets but failed to mention that you have to cd to the sdkpath and the tools directory to find that command. And also fails to mention how to change it from android-7 to android-15. Note that in the packager.json file I did have: "androidAPILevel":"15",

chintan
16th Oct '12
  0  

using SDK Tools Beta 3, sencha touch 2.0.1.1, Ubuntu 10

sencha package generate packager.json

[ERROR] /bin/sh: stbuild: not found

florianspallek
30th Oct '12
  0  

Hello,

I have the same problem here. I build the same app like in the "Getting Started" video. If I try to generate the android app with the "sencha app build native" command, the generator freezes at the step "Packaging your application as a native app...".

Any Ideas?

Regards, Florian

techtigre
2nd Nov '12
  0  

Make sure you have Apache Ant installed in your environment properly. I spent hours on this only to find my Windows PATH variable did not include my ANT or ANT/bin directory. The sencha packager creates a build.xml file when launched and ANT has to be available on your PATH to execute properly.

techtigre
2nd Nov '12
  0  

Also, it does seem that the parameter "androidAPILevel" in the packager.json file does not get reflected in the actual build. I too noticed that it's using --target android-7 no matter what this param is set to. So as a result, if you do NOT have the Android 2.1 (API 7) installed on your machine you will get errors during your build. I used Android's SDK manager to install ALL versions of Android from 2.1 to 4.1 to work around this issue.

burrellramone
29th Nov '12
  0  

Im suprised that almost everyone who left a comment has/had a problem. I can thereby conclude that this walkthrough is not very thorough.

burrellramone
30th Nov '12
  0  

After i installed the apk file on the andoid emulator it says that it cannot file a url that uses the filesystem protocl file:///. Please help.

arsuceno
23rd Jan '13
  3  

Worst guide ever o_O. If you are using Windows check paths of everything (Java JDK, Ant, Sencha SDK Tools...). It is better if you don't use spaces in your paths. Also, running:

sencha app build native

Which will give you a packager.temp.json ready to be launched by sencha package run packager.temp.json . I haven't been able to run the app in Android Emulator without building native before.

CalFord
8th Oct '13
  0  

Is there ANYONE on the planet that is a book or video or docs that actually makes this Sencha product work from install to packaging. Very disappointed over the extreme difficulty this product generates. And its the little things the company misses (or chooses to omit).

GeorgeHoffer
8th Oct '13
  0  

Please consider upgrading to the current version. Touch 2.3.0 and Sencha Cmd 4 help make native packaging understandable--we've done a lot of work to simplify native packaging and improve the docs. Plus in Touch 2.3.0, you get access to the new Apache Cordova interface and wide array of new functionality. See http://docs.sencha.com/touch/2.3.0/ for more information.

转载于:https://www.cnblogs.com/xiari/p/3479689.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值