Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse doesn't generate MainActivity.java & activity_main.xml

On creating a new Android Application Project, MainActivity.java under its package name should be generated automatically in src folder & activity_main.xml should be created inside layout folder. But it is not created.

enter image description here

And also in manifest it doesn`t generate this POC

 <activity
        android:name="info.androidhive.slidingmenu.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>

However, I added all these things manually.

  • activity_main.xml then shows this error

     Eclipse is loading framework information and the layout library from the SDK folder.
     activity_main.xml will refresh automatically once the process is finished.
    
  • MainActivity.java doesn't recognize the layout field in setContentView(R.layout.activity_main)

And yesterday I downloalded the updates from SDK Manager these tools are installed /updatedenter image description hereenter image description here

I tried cleaning the project,changing the workspace,restarting the eclipse & windows but it doesn't helps :(

like image 921
Vivek Warde Avatar asked Mar 09 '14 04:03

Vivek Warde


People also ask

What is MainActivity Java file?

The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World!

Where is the MainActivity Java in flutter?

1- Navigate to the directory holding your Flutter app, and select the android folder inside it. Click OK. 2- Open the MainActivity. java file located in the java folder in the Project view.

Where is Activity_main XML located?

activity_main. xml: This file located in the res/layout folder. It defines what components to display and how to display them in referenced activity view. Double click this file, you can see the content in the right panel, it has a Design view and a Text view, you can click the bottom Design and Text tab to switch.

How do I rename my MainActivity?

Yes, you can change the name of MainActivity by, opening the directory of the java file in android studio, right-click on it and find refactor, then rename, put in the name you like then click on refactor.


1 Answers

I solved problem by changing method while creating new project... Don't know why but after updating ADT to latest version, when we create "blank activity", it generates empty src and res folders but if we create new "Empty activity", it generates default hello world program like in previous versions of ADT.... SO just click on create empty activity when new android project is to be added

like image 72
SK16 Avatar answered Oct 07 '22 09:10

SK16