package org.WTFpro; import android.app.Activity; import android.os.Bundle; import android.content.Intent; import android.net.Uri; import android.view.View; import android.widget.Button;  public class WTFproActivity extends Activity {     Button btnActTwo;     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.menu);         btnActTwo = (Button) findViewById(R.id.btnActTwo);     }     public void goNewView(View v){         switch (v.getId()) {             case R.id.btnActTwo:                 Intent intent = new Intent(this, NewActivity.class);                 startActivity(intent);                 break;             default:                 break;         }     } } public class WTFproActivity extends Activity { Button mBtn;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.menu);          mBtn = (Button) findViewById(R.id.btn12);         mBtn.setOnClickListener(new View.OnClickListener() {             @Override       public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW,      Uri.parse("http://google.com")));             }         });     } } 

Unfortunately, I'm just starting to master the android, so I apologize right away if the question is stupid. But when compiling somewhere in this code, an error occurs. Tell me where is she?

In the log specified as follows:

1. ERROR in *** / projects / WTFpro / src / org / WTFpro / WTFproActivity.java (at line 34) public class WTFproActivity extends Activity {^^^^^^^^^^^^^^^^ The type WTFproActivity is already defined

  • To understand, you need to see the logs. They need to watch in LogCat. But there is an assumption that your "NewActivity" is not declared either as a class or in a manifest. - Yuriy SPb
  • 2
    WTFproActivity 2a of the same name - Gorets
  • @Denbka, "two identical names of different activities", are you serious? - AseN

2 answers 2

Judging by the logs:

Each activity must be declared in a separate file, have a unique, non-repeated name and must be specified in the manifest.

  • one
    Thank you so much. Understood, everything works. - Denbka
  • @Denbka, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Yuriy SPb

Name the 2 activity NewActivity. You have 2 identical names.

  • Ferried, did not help. Now: 1. ERROR in **** / projects / WTFpro / src / org / WTFpro / WTFproActivity.java (at line 34) public class NewActivity extends Activity {^^^^^^^^^^^^^^ The public type ERROR in **** / projects / WTFpro / src / org / WTFpro / NewActivity.java (at line 6) public class NewActivity extends Activity {^^^^^^^^^ ^^^ The type NewActivity is already Dencka
  • @Denbka, translate.google.com - Yura Ivanov