问题
I've been working on some projects in my programming class and copied them to my computer at home so I can keep working on them.
When I tried to import these projects to Eclipse, it said a project named MainActivity
already exists.. Although my workspace folder is clear.
As you can see in the picture the import wizard sets "New Project Name"
as MainActivity
, for all of the projects I'm trying to import.I'm pretty sure thats causing the errors.
How can I import projects and keep the original name without the import wizard changing it to MainActivity
?
http://i.stack.imgur.com/NSQ4y.png
回答1:
On the screen indicated by your screenshot, you can rename each "MainActivity" to something more unique and relevant by clicking in each text field under "New Project Name". It's not immediately apparent that this field is editable, but it is.

回答2:
This works for me...
Go to your project src folder. Open the ".project" file...
You can change the name here:
...
<projectDescription>
<name>my_desired_name</name>
...
回答3:
You can simply do the following: rather than opening your projects you will create duplicates. open eclipse>file>new>other>android>android project from existing code.
then you simply browse your computer for your projects.
回答4:
It won't allow you to import MainActivity because you already have one... So, let's rename the one you have so it will allow you to bring in the new one...
Open the Project Explorer View (Window->ShowView->ProjectExplorer) Find MainActivity and right click on it... Refactor->Rename
Once it's renamed, Eclipse will allow you to import the new one.
回答5:
1) In a text editor (eg. Notepad.exe) open AndroidManifest.xml from the project that fails to import.
2) look for android:name and change it.
For example, I changed android:name="com.example.android.location.MainActivity" to android:name="com.example.android.location.XMainActivity"
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="JDLocation Updates"
android:description="@string/app_description"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.android.location.XMainActivity"
android:label="JDLocation Updates">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.example.android.location.ReceiveUpdatesIntentService"
android:label="JDLocation Updates"
android:exported="false"></service>
</application>
来源:https://stackoverflow.com/questions/17576166/why-i-cant-import-existing-project-to-eclipse