Sencha Touch 2 Native Packaging for Android-程序员宅基地

技术标签: 开发工具  json  移动开发  

准备

打包安卓应用

  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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30906185/article/details/98905037

智能推荐

攻防世界_难度8_happy_puzzle_攻防世界困难模式攻略图文-程序员宅基地

文章浏览阅读645次。这个肯定是末尾的IDAT了,因为IDAT必须要满了才会开始一下个IDAT,这个明显就是末尾的IDAT了。,对应下面的create_head()代码。,对应下面的create_tail()代码。不要考虑爆破,我已经试了一下,太多情况了。题目来源:UNCTF。_攻防世界困难模式攻略图文

达梦数据库的导出(备份)、导入_达梦数据库导入导出-程序员宅基地

文章浏览阅读2.9k次,点赞3次,收藏10次。偶尔会用到,记录、分享。1. 数据库导出1.1 切换到dmdba用户su - dmdba1.2 进入达梦数据库安装路径的bin目录,执行导库操作  导出语句:./dexp cwy_init/[email protected]:5236 file=cwy_init.dmp log=cwy_init_exp.log 注释:   cwy_init/init_123..._达梦数据库导入导出

js引入kindeditor富文本编辑器的使用_kindeditor.js-程序员宅基地

文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js

STM32学习过程记录11——基于STM32G431CBU6硬件SPI+DMA的高效WS2812B控制方法-程序员宅基地

文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6

计算机网络-数据链路层_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输

软件测试工程师移民加拿大_无证移民,未受过软件工程师的教育(第1部分)-程序员宅基地

文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...

随便推点

Thinkpad X250 secure boot failed 启动失败问题解决_安装完系统提示secureboot failure-程序员宅基地

文章浏览阅读304次。Thinkpad X250笔记本电脑,装的是FreeBSD,进入BIOS修改虚拟化配置(其后可能是误设置了安全开机),保存退出后系统无法启动,显示:secure boot failed ,把自己惊出一身冷汗,因为这台笔记本刚好还没开始做备份.....根据错误提示,到bios里面去找相关配置,在Security里面找到了Secure Boot选项,发现果然被设置为Enabled,将其修改为Disabled ,再开机,终于正常启动了。_安装完系统提示secureboot failure

C++如何做字符串分割(5种方法)_c++ 字符串分割-程序员宅基地

文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割

2013第四届蓝桥杯 C/C++本科A组 真题答案解析_2013年第四届c a组蓝桥杯省赛真题解答-程序员宅基地

文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答

基于供需算法优化的核极限学习机(KELM)分类算法-程序员宅基地

文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。

metasploitable2渗透测试_metasploitable2怎么进入-程序员宅基地

文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入

Python学习之路:从入门到精通的指南_python人工智能开发从入门到精通pdf-程序员宅基地

文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf

推荐文章

热门文章

相关标签