6

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?

https://i.stack.imgur.com/NSQ4y.png

Noams98
  • 63
  • 1
  • 1
  • 4

5 Answers5

7

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.

enter image description here

Kyle Falconer
  • 8,302
  • 6
  • 48
  • 68
  • @user2569406 - I added a picture. I am able to just click on "MainActivity" right there and change the text to whatever I want. – Kyle Falconer Jul 10 '13 at 16:55
  • 1
    Thank you!it worked.. and thanks for everyone else who tried to help! if i just had enough reputation i would vote helpful on all of your answers... – Noams98 Jul 10 '13 at 16:57
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>
...
2

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>
JDOaktown
  • 4,262
  • 7
  • 37
  • 52
1

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.

SALAMAT Med Ayman
  • 673
  • 1
  • 10
  • 16
1

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.

jimrooney
  • 71
  • 6