0

When I run the analize it on comes back with one error in the manafest android name = is not public but when i build it says built with no error but when i run it on my emu and my tablet it crashes i can not figure this out please help. This is my code with names omitted.

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.xxxx.xxxx.app.MainActivity"
android:background="@drawable/appbackground">
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/facebook"
 android:id="@+id/button1"
 android:background="@drawable/facebook"
 android:clickable="true"
 android:enabled="true"
 android:gravity="end"
 android:width="50dp"
 android:layout_alignParentTop="true"
 android:layout_alignRight="@+id/button3"
 android:layout_alignEnd="@+id/button3" />
 <Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/dealer"
 android:id="@+id/button2"
 android:enabled="true"
 android:background="@drawable/dealer"
 android:clickable="true"
 android:layout_alignParentTop="true"
 android:layout_alignLeft="@+id/button4"
 android:layout_alignStart="@+id/button4" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/map"
 android:id="@+id/button3"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/google_navigation"
 android:layout_below="@+id/button1"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:layout_marginTop="29dp" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/about"
 android:id="@+id/button4"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/about"
 android:layout_alignBottom="@+id/button3"
 android:layout_alignParentRight="true"
 android:layout_alignParentEnd="true" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/pthdh"
 android:id="@+id/button5"
 android:layout_below="@+id/button3"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:layout_marginTop="25dp"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/pthdh" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/rpe"
 android:id="@+id/button6"
 android:layout_alignTop="@+id/button5"
 android:layout_alignParentRight="true"
 android:layout_alignParentEnd="true"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/rpebutton" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/call"
 android:id="@+id/button7"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/callus"
 android:layout_alignParentBottom="true"
 android:layout_centerHorizontal="true" />
<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/contact"
 android:id="@+id/button8"
 android:enabled="true"
 android:clickable="true"
 android:background="@drawable/contact"
 android:layout_marginBottom="31dp"
 android:layout_above="@+id/button7"
 android:layout_centerHorizontal="true" />
<TextClock
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/textClock"
 android:textStyle="bold"
 android:textColor="#000000"
 android:background="#ff5300"
 android:gravity="center"
 android:textSize="30sp"
 android:textIsSelectable="true"
 android:layout_above="@+id/button8"
 android:layout_alignLeft="@+id/button8"
 android:layout_alignStart="@+id/button8"
 android:layout_marginBottom="34dp" />
</RelativeLayout>

MainActivity.java

package com.xxxx.xxxx.app;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
class MainActivity extends Activity implements OnClickListener{
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 Button button1 = (Button) findViewById(R.id.button1);
 Button button2 = (Button) findViewById(R.id.button2);
 Button button3 = (Button) findViewById(R.id.button3);
 Button button4 = (Button) findViewById(R.id.button4);
 Button button5 = (Button) findViewById(R.id.button5);
 Button button6 = (Button) findViewById(R.id.button6);
 Button button7 = (Button) findViewById(R.id.button7);
 Button button8 = (Button) findViewById(R.id.button8);
 button1.setOnClickListener(this);
 button2.setOnClickListener(this);
 button3.setOnClickListener(this);
 button4.setOnClickListener(this);
 button5.setOnClickListener(this);
 button6.setOnClickListener(this);
 button7.setOnClickListener(this);
 button8.setOnClickListener(this);
 }
 @Override
 public void onClick(View v) {
 switch(v.getId()){
 case R.id.button1:
 Intent intent = new Intent(Intent.ACTION_VIEW);
 intent.setClassName("com.facebook.katana",
 "com.facebook.katana.ProfileTabHostActivity");
 Long uid = new Long("xxxx");
 intent.putExtra("extra_user_id", uid);
 startActivity(intent);
 break;
 case R.id.button2:
 intent = new Intent(Intent.ACTION_VIEW, Uri.parse
 ("http://www.xxxx.com"));
 startActivity(intent);
 break;
 case R.id.button3:
 Uri location = Uri.parse("geo:xx.xxx7629,-xx.xxxx584?z=14");
 new Intent(Intent.ACTION_VIEW, location);
 break;
 case R.id.button4:
 intent = new Intent(Intent.ACTION_VIEW, Uri.parse
 ("http://www.xxxx.com/default.asp?page=info"));
 startActivity(intent);
 break;
 case R.id.button5:
 intent = new Intent(Intent.ACTION_VIEW, Uri.parse
 ("http://www.xxxx.com/"));
 startActivity(intent);
 break;
 case R.id.button6:
 intent = new Intent(Intent.ACTION_VIEW, Uri.parse
 ("https://members.xxxx.com/"));
 startActivity(intent);
 break;
 case R.id.button7:
 Intent dial = new Intent();
 dial.setAction("android.intent.action.DIAL");
 dial.setData(Uri.parse("tel:xxxx"));
 startActivity(dial);
 break;
 case R.id.button8:
 intent = new Intent(Intent.ACTION_VIEW, Uri.parse
 ("http://www.xxxx.com/default.asp?page=xcontact"));
 startActivity(intent);
 break;
 default:
 Log.d(getApplication().getPackageName(), "Button click error!");
 break;
 }
 }
 @Override
public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu; this adds items to the action bar if it is present.
 getMenuInflater().inflate(R.menu.main, menu);
 return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
 // Handle action bar item clicks here. The action bar will
 // automatically handle clicks on the Home/Up button, so long
 // as you specify a parent activity in AndroidManifest.xml.
 int id = item.getItemId();
 return id == R.id.action_settings || super.onOptionsItemSelected(item);
}
}

AndroidManifest xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxxx.xxxx.app" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
 android:name="com.xxxx.xxxx.app.MainActivity"
 android:label="@string/app_name" >
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
</activity>
<meta-data
 android:name="com.google.android.maps.v2.API_KEY"
 android:value="xxxxxxxxxxxxxxxxxxxx"/>
</application>
</manifest>
asked Mar 15, 2014 at 22:17
2
  • 1
    and please post your stacktrace/logcat. Commented Mar 15, 2014 at 22:18
  • ill post those as soon as i can i'm headed out for the weekend will post monday Commented Mar 15, 2014 at 22:35

1 Answer 1

2

You have to put "public" before "class":

 public class MainActivity extends Activity implements OnClickListener
answered Mar 15, 2014 at 22:24
Sign up to request clarification or add additional context in comments.

7 Comments

seriously that was all that was jacking me up
it still crashes as soon as click on it it goes to unfortunately XXXX has stopped
Ok, please post your stacktrace/logcat. If you do, we won't have to read through your code. It should state pretty clearly what the problem is.
ok i will when i get back Monday i cant get to the computer with the info till then but thank you on the manifest issue that fixed right away cant beleave i missed that
It might be another issue. Accept this answer (or not) and post a new question in that case. Good luck.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.