tags:

views:

215

answers:

1

Hi all,

I have copied and pasted the code from the Form stuff example on this website. I am getting an error when i try and run the project, the project has a little red square with a white cross on it but when drilling down into the elements of the project (using eclipse) there is element with an error. In the problems tab of eclipse I have the following text

Description Resource Path Location Type Unparsed aapt error(s)! Check the console for output. HelloFormStuff2 Unknown Android Packaging Problem

But there is nothing in the console!! Here is the code and elements that I am using...

HelloFormStuff2.java package com.android.HelloLinearLayouts;

import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast;

public class HelloFormStuff2 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

    final Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // Perform action on clicks
            Toast.makeText(HelloFormStuff2.this, "Beep Bop", Toast.LENGTH_SHORT).show();
        }
    });

}

}

res/drawable-hdpi/android-button.xml

res/layout/main.xml android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

+1  A: 

Not sure what happened to your code in the question, but check under res/layout/ and make sure there's not a main-out.xml. If there is, delete it, do Project > Clean, and then run the application by right-clicking the project and selecting Run As > Android Application.

Coming from Visual Studio, I kept trying to just do a "run as" from anywhere, which doesn't work in Eclipse (unless I'm doing something else wrong); instead, it tries to run the xml file, which gave me that error all the time.

If I'm completely off-base, just try Project > Clean..., then Project > Build All (if it's not set to automatic).

kcoppock
That worked! I did the clean and, no idea what the problem was, but it is now running! :) Thankyou for your help amigo!
Stephen