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.
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 /updated
I tried cleaning the project,changing the workspace,restarting the eclipse & windows but it doesn't helps :(
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
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
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.
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.
Without that, my project looks the same as yours:
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.
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.
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.
I have solved this problem in the following way.
- Download Eclipse from official site ( current version 4.4.0 Luna).
- Install it.
- Run Eclipse Help->Install new software
- Enter in empty top field `https://dl-ssl.google.com/android/eclipse/ click add and name it as you want , for instance AndroidPlugin
- Install all software( Developes tools)
- Restart Eclipse
- Eclipse should show error message that your sdk is not found
- Specify your SDK in Use existing sdk .
- Restart Eclipse.
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'.
来源:https://stackoverflow.com/questions/22278479/eclipse-doesnt-generate-mainactivity-java-activity-main-xml