19

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 :(

Vivek Warde
  • 1,936
  • 8
  • 47
  • 77

9 Answers9

13

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

SK16
  • 623
  • 8
  • 17
  • actually after some duration i switched to Eclipse Luna with android plugin instead of ADT because after update ADT has caused several issues like this one...It doesn't generate template codes for google maps or any other activities. Eclipse luna with Android plugin is better. – SK16 Oct 09 '14 at 15:50
  • 1
    After several hours of trying (tried the approved solution/reinstall) I just gave up and used this... – JohnnyAce Dec 15 '14 at 03:43
  • I tried this, but anther issue happened, the style.xml which should inside res folder was not generated. – liam xu Dec 18 '14 at 14:48
  • @liam xu....switch to eclipse + android plugin...its better...else give a go to android studio.. – SK16 Dec 23 '14 at 11:11
6

As one guy said

I had the same problem even though I downloaded the Android SDK and did a clean install, but I just resolved it. I tried to click "Help" -> "Check for updates", and then I got a pop-up message saying everything was up to date, but after further research it appeared to me it wasn't up to date. What you need to do is click "Help" -> "Install new software" and install (this will update it) from this url: https://dl-ssl.google.com/android/eclipse/

See here thread https://code.google.com/p/android/issues/detail?id=66647

Ajay S
  • 48,003
  • 27
  • 91
  • 111
  • I m getting this problem after implementing ur answer http://stackoverflow.com/questions/22344320/eclipse-error-in-xml-graphical-layout-after-the-new-update – Vivek Warde Mar 12 '14 at 07:11
  • I see, wait for a second to load your layout. – Ajay S Mar 12 '14 at 14:27
  • 1
    Ah, okay the question which you asked here seems you have found the solution from this answer, the issue which you are describing is new so wait for a while might I will reply to the question where you asked this http://stackoverflow.com/questions/22344320/eclipse-error-in-xml-graphical-layout-after-the-new-update – Ajay S Mar 12 '14 at 15:04
  • This seemed to be an issue prior to Android SDK tools Revision 24.0.2. Check this http://developer.android.com/tools/sdk/tools-notes.html Google has fixed it – Sheraz Ahmad Khilji Dec 29 '14 at 08:01
2

Same thing happened to me couple days ago after updating SDK through android SDK Manager. When I rebooted eclipse, I got a pop-up saying my Android Development Tool (ADT) or a plugin for Eclipse needs update to version 22.6.2

Here is the information http://developer.android.com/tools/sdk/eclipse-adt.html

and click updating ADT, the download instructions are in there.

I copied it out here just in case,

Download the ADT Plugin Start Eclipse, then select Help > Install New Software. Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/ Note: The Android Developer Tools update site requires a secure connection. Make sure the update site URL you enter starts with HTTPS. Click OK. In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded. Click Next. Read and accept the license agreements, then click Finish. If you get a security warning saying that the authenticity or validity of the software can't be established, click OK. When the installation completes, restart Eclipse.

Hope this helps.

0

There is an option to select whether to generate MainActivity and activity_main.xml. Are you sure that you have selected those ? Make sure to select that.

enter image description here

Without that, my project looks the same as yours:

enter image description here

An SO User
  • 24,612
  • 35
  • 133
  • 221
0

Those solutions didn't work for me too, but what resolve the problem for me was deleting the appcompat projects that are auto-created when we create a new android application project.

0

I was having the same problem. I tried creating the project with a different Target SDK. I used API 16 Android 4.1 and that worked.

doohsam
  • 47
  • 3
  • 8
0

I was also facing the same problem, had the adt and sdk tool updated to v23 which was released on 6/24. Created a project with Target SDK - AP1 16 and compile with API 19 and activity was created.

Chinmayee
  • 1
  • 1
0

I have solved this problem in the following way.

  1. Download Eclipse from official site ( current version 4.4.0 Luna).
  2. Install it.
  3. Run Eclipse Help->Install new software
  4. Enter in empty top field `https://dl-ssl.google.com/android/eclipse/ click add and name it as you want , for instance AndroidPlugin
  5. Install all software( Developes tools)
  6. Restart Eclipse
  7. Eclipse should show error message that your sdk is not found
  8. Specify your SDK in Use existing sdk .
  9. Restart Eclipse.
Sufian
  • 6,405
  • 16
  • 66
  • 120
0

Since this query isn't solved, I would like to add from my experience;

I agree with "SK17" 's advice.. The latest eclipse software somehow generates the MainActivity.xml file by choosing 'Empty Activity' instead of 'Blank Activity'.

Nevertheless, for some systems, you might also try changing the target SDK to Android 'JellyBean' or 'KitKat' rather than 'API21'.

naps73r
  • 21
  • 4