Noams98
Noams98

Reputation: 63

Why I can't Import existing project to eclipse?

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.sstatic.net/NSQ4y.png

Upvotes: 6

Views: 11912

Answers (5)

JDOaktown
JDOaktown

Reputation: 4474

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>

Upvotes: 2

user2297764
user2297764

Reputation:

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>
...

Upvotes: 2

jimrooney
jimrooney

Reputation: 71

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.

Upvotes: 1

SALAMAT Med Ayman
SALAMAT Med Ayman

Reputation: 673

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.

Upvotes: 1

Kyle Falconer
Kyle Falconer

Reputation: 8510

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

Upvotes: 7

Related Questions