日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

第二步 (仅供参考) sencha touch + PhoneGap(cordova 2.9 及其以下版本) 使用 adt eclipse进行打包...

發(fā)布時(shí)間:2025/7/14 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第二步 (仅供参考) sencha touch + PhoneGap(cordova 2.9 及其以下版本) 使用 adt eclipse进行打包... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

首先你得安裝一個(gè)adt-eclipse

參考資料

http://www.crifan.com/android_eclipse_offline_install_adt/

然后就可以運(yùn)行adt-eclipse來進(jìn)行打包

1.新建Android一個(gè)項(xiàng)目

打開Eclipse,單擊菜單欄的“File”->把鼠標(biāo)光標(biāo)移動(dòng)到“New”->在彈出的列表框中,如果直接能看到“Android Applicaion Project”選項(xiàng)項(xiàng),則直接單擊此選項(xiàng),否則選擇最下面的“Other...”,在彈出的窗口中,展開“Android”項(xiàng),選擇“Android Applicaion Project”,然后“Next”;

其實(shí)還有一個(gè)方法就是直接點(diǎn)Eclipse工具欄的如下圖所指示的圖標(biāo):

在新彈出的窗口中按下圖提s示填寫相關(guān)信息,一路“Next”,直到點(diǎn)擊“Finish”,這樣第一個(gè)Android程序就創(chuàng)建好了,這是你會(huì)發(fā)現(xiàn)Eclipse左邊多了一個(gè)你新創(chuàng)建的Android項(xiàng)目。

2.將sencha touch項(xiàng)目導(dǎo)入

因?yàn)樾枰尤隿ordova,所以我們需要從http://cordova.apache.org/下載一個(gè)cordova的包

http://archive.apache.org/dist/cordova/cordova-2.6.0-src.zip我現(xiàn)在用的是2.6版本的

在安卓項(xiàng)目中結(jié)構(gòu)目錄如下:

如圖我們需要將cordova的jar包引入,然后需要在res/xml目錄下加入cordova的配置文件config.xml

代碼如下:

1 <?xml version="1.0" encoding="utf-8"?> 2 <!-- 3 Licensed to the Apache Software Foundation (ASF) under one 4 or more contributor license agreements. See the NOTICE file 5 distributed with this work for additional information 6 regarding copyright ownership. The ASF licenses this file 7 to you under the Apache License, Version 2.0 (the 8 "License"); you may not use this file except in compliance 9 with the License. You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, 14 software distributed under the License is distributed on an 15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 KIND, either express or implied. See the License for the 17 specific language governing permissions and limitations 18 under the License. 19 --> 20 <cordova> 21 <!-- 22 access elements control the Android whitelist. 23 Domains are assumed blocked unless set otherwise 24 --> 25 26 <access origin="http://127.0.0.1*"/> <!-- allow local pages --> 27 28 <!-- <access origin="https://example.com" /> allow any secure requests to example.com --> 29 <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www --> 30 <access origin=".*"/> 31 32 <!-- <content src="http://mysite.com/myapp.html" /> for external pages --> 33 <content src="index.html" /> 34 35 <log level="DEBUG"/> 36 <preference name="useBrowserHistory" value="true" /> 37 <preference name="exit-on-suspend" value="false" /> 38 <plugins> 39 <plugin name="App" value="org.apache.cordova.App"/> 40 <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/> 41 <plugin name="Device" value="org.apache.cordova.Device"/> 42 <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/> 43 <plugin name="Compass" value="org.apache.cordova.CompassListener"/> 44 <plugin name="Media" value="org.apache.cordova.AudioHandler"/> 45 <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/> 46 <plugin name="Contacts" value="org.apache.cordova.ContactManager"/> 47 <plugin name="File" value="org.apache.cordova.FileUtils"/> 48 <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/> 49 <plugin name="Notification" value="org.apache.cordova.Notification"/> 50 <plugin name="Storage" value="org.apache.cordova.Storage"/> 51 <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/> 52 <plugin name="Capture" value="org.apache.cordova.Capture"/> 53 <plugin name="Battery" value="org.apache.cordova.BatteryListener"/> 54 <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/> 55 <plugin name="Echo" value="org.apache.cordova.Echo" /> 56 <plugin name="Globalization" value="org.apache.cordova.Globalization"/> 57 <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/> 58 </plugins> 59 </cordova>

然后需要修改AndroidManifest.xml進(jìn)行權(quán)限配置等

代碼如下:

1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.jy110" 4 android:hardwareAccelerated="true" 5 android:versionCode="1" 6 android:versionName="1.0" 7 android:windowSoftInputMode="adjustPan" > 8 9 <supports-screens 10 android:anyDensity="true" 11 android:largeScreens="true" 12 android:normalScreens="true" 13 android:resizeable="true" 14 android:smallScreens="true" 15 android:xlargeScreens="true" /> 16 17 <uses-sdk 18 android:minSdkVersion="8" 19 android:targetSdkVersion="16" /> 20 21 <uses-permission android:name="android.permission.CAMERA" /> 22 <uses-permission android:name="android.permission.VIBRATE" /> 23 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 24 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 25 <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 26 <uses-permission android:name="android.permission.INTERNET" /> 27 <uses-permission android:name="android.permission.RECEIVE_SMS" /> 28 <uses-permission android:name="android.permission.RECORD_AUDIO" /> 29 <uses-permission android:name="android.permission.RECORD_VIDEO" /> 30 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 31 <uses-permission android:name="android.permission.READ_CONTACTS" /> 32 <uses-permission android:name="android.permission.WRITE_CONTACTS" /> 33 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 34 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 35 <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 36 <uses-permission android:name="android.permission.BROADCAST_STICKY" /> 37 38 <application 39 android:allowBackup="true" 40 android:icon="@drawable/ic_launcher" 41 android:label="@string/app_name" 42 android:theme="@style/AppTheme" > 43 <activity 44 android:name="com.example.jy110.Jy110Activity" 45 android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" 46 android:label="@string/app_name" 47 android:theme="@android:style/Theme.Black.NoTitleBar" > 48 <intent-filter> 49 <action android:name="android.intent.action.MAIN" /> 50 51 <category android:name="android.intent.category.LAUNCHER" /> 52 </intent-filter> 53 </activity> 54 </application> 55 56 </manifest>

現(xiàn)在環(huán)境基本配置完成了,接下來就把我們的html5項(xiàng)目引入進(jìn)去

我們將做好的項(xiàng)目放進(jìn)一個(gè)www的文件,如下圖:

然后將整個(gè)www文件放入安卓項(xiàng)目的assets目錄下

然后修改src之中的項(xiàng)目啟動(dòng)文件,我這里是Jy110Activity文件,代碼如下

1 package com.example.jy110; 2 3 import org.apache.cordova.DroidGap; 4 5 import android.annotation.TargetApi; 6 import android.os.Bundle; 7 8 9 public class Jy110Activity extends DroidGap { 10 private int retryCount = 0; 11 @Override 12 public void onCreate(Bundle savedInstanceState) { 13 super.onCreate(savedInstanceState); 14 //設(shè)置啟動(dòng)圖片 15 super.setIntegerProperty("splashscreen", R.drawable.splash); 16 super.init(); 17 //解決4.1以上安卓白屏問題 18 if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { 19 fixJellyBeanIssues(); 20 } 21 //運(yùn)行html5項(xiàng)目 22 super.loadUrl("file:///android_asset/www/index.html",5000); 23 } 24 25 @TargetApi(16) 26 protected void fixJellyBeanIssues() { 27 System.out.println(super.appView.toString()); 28 try { 29 super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true); 30 } catch(NullPointerException e) { 31 System.out.println(e.toString()); 32 } 33 } 34 35 @Override 36 public void onReceivedError( int errorCode, String description, String failingUrl) 37 { 38 if(retryCount < 3) { 39 retryCount++; 40 super.loadUrl("file:///android_asset/www/index.html"); 41 } else { 42 super.loadUrl("file:///android_asset/www/fail.html"); 43 } 44 return; 45 } 46 47 }

在st項(xiàng)目中引入cordova.js文件,在app.js中加入以下代碼

Ext.Loader.setConfig({enabled: true }); /* *請(qǐng)自行添加模擬數(shù)據(jù) *這里涉及到了 *路由:controller.Main *List:view.img.List *歷史記錄支持、自動(dòng)銷毀、自定義消息提示:view.img.util.CardPanel *登錄、注冊(cè):controller.User和view.user *Carousel:view.img.List和controller(除開user) *如有問題請(qǐng)聯(lián)系qq:534502520 q群:224711028 213119459@魔狼再世 歡迎交流 *此版本已在安卓中打包測(cè)試 */ Ext.application({name: 'app',appFolder: 'app',controllers: ['Main', 'User','Img'],views: ['util.CardPanel'],//請(qǐng)求地址postUrl: 'http://localhost:40231/PictureManager/mynetpic/',//過期時(shí)間sessionTimeout: 1000 * 60 * 60 * 24 * 30,launch: function () {Ext.Viewport.add({xclass: 'app.view.util.CardPanel'});// 等待加載PhoneGapdocument.addEventListener("deviceready", onDeviceReady, false);// PhoneGap加載完畢后執(zhí)行,這樣就可以在項(xiàng)目中使用PhoneGap調(diào)用手機(jī)硬件function onDeviceReady() {}} });

這樣就算完成了,之后就是打包項(xiàng)目了。

3.簽名打包

Eclipse工程中右鍵工程,彈出選項(xiàng)中選擇 android工具-生成簽名應(yīng)用包:

選擇需要打包的android項(xiàng)目工程:

如果已有私鑰文件,選擇私鑰文件輸入密碼,如果沒有參見第6和7步創(chuàng)建私鑰文件:

4.輸入私鑰別名和密碼:

5.選擇APK存儲(chǔ)的位置,并完成設(shè)置 開始生成:

6.沒有私鑰文件的情況,創(chuàng)建私鑰文件:

7.輸入私鑰文件所需信息,并創(chuàng)建:

*SDK的安裝目錄最后不要有中文和空格,否則會(huì)出現(xiàn)不必要的錯(cuò)誤。如果你的安裝路徑包含Program Files(有空格),用ADT打包會(huì)報(bào)錯(cuò),Ant方式打包的也會(huì)報(bào)錯(cuò),沒關(guān)系,不用重裝,解決方法:配置SDk環(huán)境變量和在Eclipse中配置SDK路徑的時(shí)候把Program Files改為Progra~1即可。(而且改成其他的都不行,只能是Progra~1,不信試試,這是Dos的規(guī)格)。

?附上項(xiàng)目實(shí)例一份,在adt-eclipse工具中,file-Import

選擇導(dǎo)入即可

http://download.csdn.net/detail/jy02534655/5635403

?

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的第二步 (仅供参考) sencha touch + PhoneGap(cordova 2.9 及其以下版本) 使用 adt eclipse进行打包...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。