[英]Issues creating PhoneGap project in Eclipse with Android SDK
我正在嘗試使用Eclipse和PhoneGap構建Android應用程序,但我不斷收到錯誤消息
[2013-05-21 17:47:39 - PhoneGapTest] Project has no target set. Edit the project properties to set one.
[2013-05-21 17:47:50 - PhoneGapTest] Parser exception for /PhoneGapTest/AndroidManifest.xml: Premature end of file.
...在打開項目時。 我打開項目屬性並設置目標,但是xml異常仍然存在。 我已經清理並構建了該項目,卸載並重新下載了我的android SDK並更新了我的ADT,但一切都無濟於事。 AndroidManifest.xml
為空 。 在錯誤控制台中,我有這個...
Archive for required library: 'E:/AndroidProjects/workspace/PhoneGapTest/libs/cordova-2.7.0.jar' in project 'PhoneGapTest' cannot be read or is not a valid ZIP file Build Path Problem
啊,現在我看到項目中的cordova jar
完全空了。 但這必須每次都發生,因為我嘗試在終端上使用PhoneGap create
命令重建該項目大約100次。 為什么會這樣呢?
編輯-好吧,現在我要直接通過下載並復制並粘貼來添加cordova jar
,但是現在當我嘗試從現有來源創建android項目時,什么也沒發生。 該文件夾甚至沒有顯示在包瀏覽器中。 那么,為什么PhoneGap命令行創建工具用一個我什至無法打開的空AndroidManifest.xml
和空cordova jar
創建一個項目?
編輯-好的,我認為至少部分問題是我在某些環境變量中使用了空格,尤其是在Program Files
。 我現在使用%PROGRAMFILES%
變量解決了這個問題,PhoneGap產生的目錄現在具有有效的cordova jar和AndroidManifest.xml
文件,大小為4KB。 這是使用PhoneGap創建命令行工具后的AndroidManifest.xml
的內容...
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="com.gsu.PhoneGapTest" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true">
<activity android:name="PhoneGapTest" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17"/>
</manifest>
...而科爾多瓦罐子的大小為251 KB。 現在這是奇怪的部分。 按照PhoneGap文檔指定的方式使用現有代碼創建帶有eclipse的android項目后,AndroidManifest.xml的內容將被刪除,減小到0 KB,並且生成的.project文件也為空。 不僅如此,但我仍然遇到相同的錯誤。 這些在控制台上...
[2013-05-21 18:27:13 - PhoneGapTest] Project has no target set. Edit the project properties to set one.
[2013-05-21 18:27:14 - PhoneGapTest] Parser exception for /PhoneGapTest/AndroidManifest.xml: Premature end of file.
..(之所以有意義是因為AndroidManifest是EMTPY),並且這些在錯誤對話框中...
Description Resource Path Location Type
Archive for required library: 'E:/AndroidProjects/workspace/PhoneGapTest/libs/cordova-2.7.0.jar' in project 'PhoneGapTest' cannot be read or is not a valid ZIP file PhoneGapTest Build path Build Path Problem
Parser exception for /PhoneGapTest/AndroidManifest.xml: Premature end of file. PhoneGapTest line 1 Android ADT Problem
The project cannot be built until build path errors are resolved PhoneGapTest Unknown Java Problem
Premature end of file. AndroidManifest.xml /PhoneGapTest line 1 Android XML Format Problem
編輯-好的,因此,如果有幫助,我創建項目的確切順序如下...
導航到phonegap*/lib/android/bin
並運行命令./create PhoneGapTest com.gsu.PhoneGapTest PhoneGapTest
。 該步驟的輸出如下:
創建新的android項目...復制模板jars ...復制js,jar和config.xml文件...復制cordova命令工具...更新AndroidManifest.xml和MainActivity ...
使用Android ADT啟動Eclipse,然后New > Project > Android > Android Project from Existing Code
導航到New > Project > Android > Android Project from Existing Code
瀏覽到在第1步中創建PhoneGapTest項目的工作區,選中copy project into workspace
復選框(如果不這樣做,則會顯示一個消息框,顯示invalid project description
),然后單擊完成。
現在,PhoneGapTest和這些錯誤一起顯示在Project Explorer中。
[2013-05-22 15:36:10-PhoneGapTest]項目未設置目標。 編輯項目屬性以設置一個。 [2013-05-22 15:36:31-PhoneGapTest] /PhoneGapTest/AndroidManifest.xml的解析器異常:文件過早結束。
...所以我點擊項目properties > Android > Project Build Target
然后選擇Android 4.2.2
(這唯一的其他選項是Google APIs
)
這里我不知道該如何處理AndroidManifest,因為它很空。 對我來說,這似乎是問題的根源。 當我從現有源代碼構建Android項目時,AndroidManifest.xml某種程度上變為空。
好的,我知道了。 我創建與PhoneGap的項目create
我的Eclipse工作區中的效用。 顯然,當您這樣做時,然后從現有的源eclipse副本和一個新的空AndroidManifest.xml
文件創建項目,這就是問題所在。 我在文件系統中的其他位置使用create
實用程序創建了該項目,並從Eclipse中的現有源創建了該項目,並且未選中copy project into workspace
復選框,並且現在一切似乎都很好,原來的AndroidManifest.xml
得以保留。
在Mac OS上,您應該使用
sudo ./create ....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.