最新版本的cmd可以直接將sencha touch項目打包成本地應用,不過還有很多不足,本文僅供參考
通過sencha app build native命令可以直接將項目打包成本地應用,不過在命令運行前需要修改項目中的packager.json文件,不然無法正確打包。
配置如下:
1 { 2 /** 3 * @cfg applicationName 4 * @required 5 * 你的應用程序名稱,只能是英文 6 */ 7 "applicationName": "jy110", 8 9 /** 10 * @cfg applicationId 11 * 你的應用的命名空間 12 */ 13 "applicationId": "com.jy110", 14 15 /** 16 * @cfg bundleSeedId 僅iOS 17 * A ten character string which stands before aplication ID in Apple Provisioning Portal 18 */ 19 "bundleSeedId": "KPXFEPZ6EF", 20 21 /** 22 * @cfg versionString 23 * @required 24 * 版本號 25 */ 26 "versionString": "1.0", 27 28 /** 29 * @cfg versionCode 30 * @required 31 * 應用內部版本號(整數) 32 */ 33 "versionCode": "1", 34 35 /** 36 * @cfg icon 37 * IOS應用圖標,參考資料 38 * https://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html 39 * 40 * Android應用圖標,參考資料 41 * http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html 42 * iOS 使用 57, 72, 114 和 144; Android 使用 36, 48 和 72;如果你打包安卓可以忽略ios的配置 43 */ 44 "icon": { 45 "36": "resources/icons/icon.png", 46 "48": "resources/icons/icon.png", 47 "57": "resources/icons/icon.png", 48 "72": "resources/icons/icon.png", 49 "114": "resources/icons/icon.png", 50 "144": "resources/icons/icon.png" 51 }, 52 53 /** 54 * @cfg inputPath 55 * @required 56 * 這是你的應用程序的位置,相對於這個配置文件。 57 */ 58 "inputPath": "./", 59 60 /** 61 * @cfg outputPath 62 * @required 63 * 應用輸出路徑。確保輸出路徑是不是在你的輸入路徑,否則會陷入死循環 64 */ 65 "outputPath": "../build/", 66 67 /** 68 * @cfg configuration 69 * @required 70 * 配置你的應用程序。 71 * `Debug`調試模式 72 * Release 正式發布 73 */ 74 "configuration": "Debug", 75 76 /** 77 * @cfg platform 78 * @required 79 * 在這里,您將運行應用程序的平台。可用選項有: 80 * - iOSSimulator iOS模擬器 81 * - iOS 82 * - Android 83 * - AndroidEmulator Android模擬器 84 */ 85 "platform": "Android", 86 87 /** 88 * @cfg deviceType 89 * @required 90 * 你的應用程序運行設備類型。 91 * 92 * 如果你開發安卓應用,不用配置 93 * 94 * Available options are: 95 * - iPhone 96 * - iPad 97 * - Universal 98 */ 99 "deviceType": "Universal", 100 101 /** 102 * @cfg certificatePath 103 * 證書路徑,可以是相對路徑也可以是絕對路徑。 104 * Android開發必須。 105 */ 106 "certificatePath": "../key.store", 107 108 /** 109 * @cfg certificateAlias 110 *這是您的證書名稱。 111 * 112 *如果您還沒有在OSX上注明這一點,我們將嘗試自動為你找到使用applicationID執行證書。 113 * 114 *這只是一個簡單的匹配。例如,如果您的證書名稱為“iPhone開發:羅伯特·杜根(ABCDEFGHIJ)”,你 115 *可以只把“iPhone開發”。 116 * 117 *當使用Windows上的certificatePath,你不需要指定。 118 */ 119 "certificateAlias": "cloudMarket", 120 /** 121 * @cfg certificatePassword 122 * 這是證書導出過程中指定的密碼 123 */ 124 "certificatePassword": "******", 125 /** 126 * @cfg provisionProfile 127 * 個人資料路徑(APP_NAME.mobileprovision),你可以創建,然后從蘋果公司的供應門戶下載 128 */ 129 "provisionProfile": "", 130 /** 131 * @cfg notificationConfiguration 132 * 推送通知的通知的配置,可以是“debug”,“release”或為空,如果你不使用推送通知在您的項目。 133 */ 134 "notificationConfiguration": "", 135 /** 136 * @cfg sdkPath 137 * 如果你正在開發一個Android應用程序,Android的SDK路徑 138 */ 139 "sdkPath": "F:/adt-eclipse/sdk", 140 141 /** 142 * @cfg androidAPILevel 143 * 這是android的API級別,關資料:http://developer.android.com/guide/appendix/api-levels.html。 144 * 必須安裝Android SDK管理器 145 */ 146 "androidAPILevel": "8", 147 148 /** 149 * @cfg {Array[String]} permissions 150 * 應用程序的權限列表(僅Android) 151 * 參考資料:http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_CHECKIN_PROPERTIES 152 */ 153 "permissions": ["INTERNET", "ACCESS_NETWORK_STATE", "CAMERA", "VIBRATE", "ACCESS_FINE_LOCATION", "ACCESS_COARSE_LOCATION", "CALL_PHONE"], 154 155 /** 156 * @cfg {Array[String]} orientations 157 * @required 158 * 屏幕控制。 159 */ 160 "orientations": ["portrait"] 161 }
然后就能在build目錄下看到打包后的apk,如圖:
通過這種打包的apk沒有啟動圖片,應用名稱也不支持中文,還帶有應用標題欄,可以參照下面的文章做一些修改。我也會查閱其他資料看看
反編譯sencha toucha打包的apk文件,修改應用名稱支持中文以及去除應用標題欄p>