Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing Existing Android Project into Eclipse

project.properties is being updated incorrectly when importing an Existing Android project into Eclipse. This file exists in source control:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=Google Inc.:Google APIs:14

After importing the project (and doing NOTHING else) the file looks like this:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8

The manifest has the following items:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="14"/>

This means that every time someone imports the project we're having to reset the build target in the project->properties->android menu. I have the latest ADT tools installed and all SDKs are downloaded and available.

Things I've tried:

  1. Deleting the entire project including contents on disk, cloning and deleting the project.properties file before importing. Same result.
  2. Deleting the entire project including contents on disk, cloning and deleting the .settings folder before importing. Same result.
  3. Deleting the entire project including contents on disk, cloning and importing just for grins. Same result.
  4. Scoured through the .project file. Nothing of interest.
  5. Double checked ant.properties, build.xml and every other plain text readable file for clues. Nothing of interest.
  6. Googled the problem and double checked the Eclipse and ADT bug sites for known issues. Nada.
  7. Verified on the file system that the file does, in fact, have the correct setting after cloning and that the import is the culprit.
  8. Deleting the entire project including contents on disk, cloning, MANUALLY editing the project.properties file to android-14, importing. This resulted in an unchanged project.properties file but since I'm using the Google APIs for mapping this is unacceptable.

I just verified that I can "fix" the project after it's imported. Delete the project from Eclipse but leaving the contents on disk. Importing the project incorrectly edits project.properties again. The import process does not recognize the Google APIs entries in project.properties.

This is how I'm getting the project from the file system into Eclipse:

enter image description here

Thoughts?

like image 423
Bill Mote Avatar asked Apr 30 '13 13:04

Bill Mote


1 Answers

For now use General -> Existing Projects into Workspace instead of the Android -> Existing Android Code into Workspace to avoid the project.properties file being auto generated improperly.

You are correct, if your android project does not have a .classpath, the android package structure is lost. But if your android project is already an Eclipse project it should import just fine.

This is a bug in eclipse. http://code.google.com/p/android/issues/detail?id=40161

This excerpt explains the problem.

"If you are importing an Eclipse project (which has a .classpath), just use the generic Eclipse project import mechanism; that's still there (Import > General > Existing Projects Into Workspace). We added Import > Android > Existing Android Code Into Workspace because a lot of people had non-Eclipse projects to import, which was not well supported; you had to "Create New" and then use a checkbox to select "existing code" etc, and the location of the project and the location of the existing sources was ambiguous. We made the Existing Android Code import option also work for Eclipse projects, such that it would be a single obvious way to pull in source code. But this is new code, not the general Eclipse builtin import code, which is why it doesn't pick up the project name in the way it used to. (The related code which handled adding new project from source did act in the same quirky way the code does now, picking a project name from the manifest). However, making it look up the project name from the .project file as a better default, if present, should be doable so I'll try to add that as well."

like image 186
josh527 Avatar answered Sep 28 '22 01:09

josh527