Question

I'm trying to build an Android app with Eclipse and PhoneGap, but I keep getting the error

[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.

...on opening the project. I open the project properties and set the target, but the xml exception persists. I've cleaned and built the project, uninstalled and redownloaded my android SDK and updated my ADT, but all to no avail. The AndroidManifest.xml is empty. In the Errors console I have this...

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

Ah, now I'm seeing that the cordova jar in the project is completely empty. But this must be happening every time, since I've tried rebuilding this project with PhoneGap create command on the terminal like 100 times. Why is this happening?

Edit - Ok, now I'm adding the cordova jar directly by copy and paste from the download, but now when I try to create the android project from existing source nothing happens. The folder doesn't even show up in the package explorer. So why is the PhoneGap command line create tool creating a project with an empty AndroidManifest.xml and empty cordova jar that I can't even open?

Edit - Ok, I think at least part of the problem was I was using spaces in some of my environment variables, specifically with Program Files. I've now taken care of that with the %PROGRAMFILES% variable, AND the directory PhoneGap produces now has a valid cordova jar and AndroidManifest.xml file at 4KB. Here's the content of AndroidManifest.xml after using the PhoneGap create command line tool...

<?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> 

...and cordova jar is 251 KB, just as it should be. Now here's the strange part. After I create the android project with eclipse using existing code just as the PhoneGap documentation specifies, the contents of the AndroidManifest.xml are deleted, back down to 0 KB, and the .project file produced is empty as well. Not only that, but I'm still getting the same errors. These on the console...

[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.

..(makes sense because the AndroidManifest is EMTPY), and these on the errors dialog...

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

EDIT - Ok, so my exact sequence for creating the project, if this helps, is the following...

  1. Navigate to phonegap*/lib/android/bin and run command ./create PhoneGapTest com.gsu.PhoneGapTest PhoneGapTest. Output from this step is the following...

    creating new android project... copying template jars... copying js, jar, and config.xml files... copying cordova command tools... updating AndroidManifest.xml and MainActivity...

  2. Fire up Eclipse with Android ADT and navigate to New > Project > Android > Android Project from Existing Code

  3. Browse to my workspace where I created the PhoneGapTest project in step 1., select the copy project into workspace checkbox (if I don't do this I get a message box reading invalid project description), click finish.

  4. Now PhoneGapTest shows up in the Project Explorer, along with these errors...

    [2013-05-22 15:36:10 - PhoneGapTest] Project has no target set. Edit the project properties to set one. [2013-05-22 15:36:31 - PhoneGapTest] Parser exception for /PhoneGapTest/AndroidManifest.xml: Premature end of file.

...so I click on the project properties > Android > Project Build Target and select Android 4.2.2 (this only other option is Google APIs)

Here I have no idea what to do about the AndroidManifest, as it is emtpy. This seems to be the root of the problem to me. When i build the Android project from existing source, the AndroidManifest.xml somehow becomes empty.

Was it helpful?

Solution

Ok got it. I was creating the project with the PhoneGap create utility inside my Eclipse workspace. Apparently when you do that and then create the project from existing source eclipse copies and a new empty AndroidManifest.xml file, which is the problem. I created the project with the create utility elsewhere in my file system, created the project from existing source within Eclipse and did not select the copy project into workspace checkbox, and everything seems fine now, the original AndroidManifest.xml was preserved.

OTHER TIPS

On mac OS, you should use

sudo ./create ....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top