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

Vivek Warde picture Vivek Warde · Mar 9, 2014 · Viewed 35.2k times · Source

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 here enter image description here

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

Answer

SK16 picture SK16 · Jul 11, 2014

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