为什么我不能将现有项目导入到 Eclipse?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17576166/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:52:32  来源:igfitidea点击:

Why I can't Import existing project to eclipse?

androideclipseimportproject

提问by Noams98

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 MainActivityalready exists.. Although my workspace folder is clear.

当我尝试将这些项目导入 Eclipse 时,它​​说一个名为的项目MainActivity已经存在..虽然我的工作区文件夹很清楚。

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.

正如您在图片中看到的,对于我尝试导入的所有项目,导入向导设置"New Project Name"MainActivity。我很确定这是导致错误的原因。

How can I import projects and keep the original name without the import wizard changing it to MainActivity?

如何导入项目并保留原始名称而无需导入向导将其更改为MainActivity

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

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

回答by Kyle Falconer

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.

在屏幕截图指示的屏幕上,您可以通过单击“新项目名称”下的每个文本字段将每个“MainActivity”重命名为更独特和相关的名称。这个字段是可编辑的并不是很明显,但确实如此。

enter image description here

在此处输入图片说明

回答by Noams98

This works for me...

这对我有用...

Go to your project src folder. Open the ".project" file...

转到您的项目 src 文件夹。打开“.project”文件...

You can change the name here:

您可以在此处更改名称:

...
<projectDescription>
    <name>my_desired_name</name>
...

回答by JDOaktown

1) In a text editor (eg. Notepad.exe) open AndroidManifest.xml from the project that fails to import.

1) 在文本编辑器(例如 Notepad.exe)中,从导入失败的项目中打开 AndroidManifest.xml。

2) look for android:name and change it.

2) 寻找 android:name 并更改它。

For example, I changed android:name="com.example.android.location.MainActivity" to android:name="com.example.android.location.XMainActivity"

例如,我将 android:name="com.example.android.location.MainActivity" 改为 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>

回答by SALAMAT Med Ayman

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.

您可以简单地执行以下操作:您将创建重复项,而不是打开您的项目。从现有代码打开 eclipse>file>new>other>android>android 项目。

then you simply browse your computer for your projects.

然后您只需浏览您的计算机以查找您的项目。

回答by jimrooney

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

它不允许你导入 MainActivity 因为你已经有了一个......所以,让我们重命名你拥有的一个,这样它就可以让你引入新的......

Open the Project Explorer View (Window->ShowView->ProjectExplorer) Find MainActivity and right click on it... Refactor->Rename

打开 Project Explorer View (Window->ShowView->ProjectExplorer) 找到 MainActivity 并右键单击它... Refactor->Rename

Once it's renamed, Eclipse will allow you to import the new one.

重命名后,Eclipse 将允许您导入新的。