Why can't android projects be imported into eclipse? - android

I have a root directory with a number of android eclipse projects inside. They all have .project files, but eclipse does not seem to see them as eclipse projects? Does anyone know the reason why?

Cause for not importing projects in eclipse :
Reason 1 : Project Structure Differs
Reason 2 : Project Configuration files missing or not available
Reason 3 : Project can be already exists in workspace
Reason 4 : Don't have Proper and Standard Naming Convention

Follow these steps.
Hope you have android sdk and ADT plugin for eclipse.
File-->Import-->Android-->Existing Android code into workspace.
Then import the projects from your root directory using Browse button. If you don't have ADT plugin definitely you never import your android projects.

You have to import them manually
First File > Import
Then General > Existing Project Into Workspace
Either select root directory or Select archive file, click Browse to locate the directory or file containing the project that you want to import
Under Projects select the project that you want to import
Finally click finish to import the project
Here is a link to the eclipse help section on this
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-importproject.htm

Related

Android Studio, Sample Code - Not working

There is sample code on the developer site that i wish to run.
When I import as a new Android Studio project, I'm not given any ability to run the code (disabled buttons).
I attempted to copy the source files over into the shell of a new project, but i than got errors that didn't make sense. reference to duplicate declarations in source files that had nothing relating inside them.
Is there an idiots guide on how to properly use android studio, or is it just this difficult?
In order to correctly import the project, you should follow the Samples guide as found in the developer docs.
To import a downloaded project:
Unpack the downloaded project package.
In Android Studio, chose File >
Import Project and select the root folder of the unpacked project.
Android Studio may ask you to choose the type of project you are
importing.
If this is the case, make sure to choose Import project
from external model and select the Gradle option.
Alternatively, if the Gradle option does not work, I would attempt to use the Eclipse option.
Open .gradle file when you import the project, not the folder of the proyect.

How to add library project to an existing android project in AndroidStudio

how can I add a custom library project (in my example the CuXtomCam library) to an existing android project using Android Studio 1.1?
I've read about changing the build.gradle file. But where should I place the library ressources?
Thank you in advance for all answers and comments!
To import library into Android Studio:
select File > Import, and then select the directory containing the project to import.
a wizard will open and guide you through the rest of the import process.
When the project import has finished, it will open up a file called "import-summary.txt" which lists all the steps taken during import and suggestions for next steps. For example, it may note files that were not migrated, it may note missing components in your SDK install, and so on.
Just right click on the project then New>Module. from the new window select Import existing project. Give the directory. I think this will help

How to import existing projects from another folder to workspace in Android studio

I want to import an existing android project into my workspace using Android Studio. I tried by the common method like File->Import project->Selected folder but the problem i am facing that the project is getting imported in to the same existing project whereas in eclipse i will be having an checkbox stating that Copy projects in to workspace(so that i can copy my projects easily by ticking the checkbox into my workspace). Since i am new to Android studio i couldn't able to trigger the hidden features to import and copy the projects in to workspace. Kindly help me by your valuable replies.
Note: currently i am copying the file from another location in to my workspace and then importing a project in to Android studio. But it is becoming tedious while handling multiple projects at a time
This is how usually to import projects to Android Studio desired workspace.
Android Studio 1.0.2
File ---> Import Project ---> (your current project folder) ---> Import Destination Directory (your workspace location) ---> Finish
I am just having the same problem.
As it happens, if you have a complete AndroidStudio / gradle project and you want to import it in Android Studio, just copy (or move, which is faster) the entire folder in your workspace, and then Use File -> Open, instead of File -> Import Project.
It seems to be exactly the same for the IDE, I can "import" and build a project flawlessly, but of course the "import" is faster (I don't really know why it is working that way).
EDIT:
after looking closely at the "opened project" structure, I think Android Studio is doing something weird. I copied the project from directory A to directory B, and I'm opening the project on directory B, but some of the files are still pointing to directory A.
I retried copying the project in directory B and then importing the project from B, instead of opening; now the references seem correct.
I solved my problem editing the file settings.gradle in the root:
include ':app', ':myAnotherModule'
project(':myAnotherModule').projectDir = new File('../my-another-project/myAnotherModule')
After run gradle sync, you can import this module inside build.gradle file:
dependencies {
//...
implementation project(':myAnotherModule')
//...
}
If you are trying to import a whole project to your workspace by creating a new application from existing code then that is very easy as long as project you are importing is on already on the folder of your workspace or there is no conflicting project on your workspace with the same name.
On the other hand if you have a project on your workspace that you are working on and you want to import other projects to it then it becomes challenging especially if you dont have a well define working sets. I suggest that you:
Open particular folders of the project you want to import for instance the "src" folder and copy the java files in it directly to your project on your eclipse (If you are using it)
Right click on the src file on your eclipse and paste the java files. It will save you the time of changing the package name on the java files.
Do the same for the resources files by copy pasting them from the respective files to the corresponding files in your project.
Then when you do this dont forget to edit the manifest file with the new changes of the activities you imported. To do this you need to look into the manifest of the project you were importing so that you do not miss a point.
It may appear tidious and cumbersome but it will help you know what exactly you imported. But you will need to change package names in the java files to the current package name.

How to import Eclipse project with source control to Android Studio without changing the directory structure to the Gradle one?

I don't have 50 reputation so I can't comment on:
https://stackoverflow.com/a/24741965/1487317
If I follow that linked solution, will the directory structure in the git repository be converted to Android Studio structure?
If not, how do I import Eclipse project with source control to Android Studio without changing the directory structure?
Yes, following that will result in the directory structure being converted to the new structure, although the history is preserved.
In order to import Eclipse project with source control to Android Studio while preserving the directory structure, do NOT import from Android Studio.
Instead, export from Eclipse the Gradle build files.
In Eclipse:
File > Export > Android > Generate Gradle build files > Next
Check the desired projects > Next
Finish
Then in Android Studio:
Import project
Navigate to the folder of the Eclipse project to import
Choose the build.gradle file (NOT THE PROJECT FOLDER)
After that, Android Studio will load the project without changing the directory structure. Note that if you import this way, the Eclipse project is NOT copied.
No. I imported an Eclipse project into Android Studio some time ago and it kept the old Eclipse structure. The importer was kind enough to just set up build.gradle to accommodate that structure.

Importing android source code as a project in eclipse

I have downloaded an android sample called custom view from android refernce from this location
http://developer.android.com/shareables/training/CustomView.zip
It only has the java files and other resources but does not contain any project file for me to import in eclipse as a project.
So when I import existing project into workspace, eclipse does not pick the project in the import dialog.
How can I import it into eclipse ? I have ADT tools installed already,
Thanks,
Ahmed
Maybe that's because you'll have to make the manifest.xml file.
What I'd suggest, is to create a new Android project, with the same package and Activity's name than in your zip (ie com.example.android.customviews and MainActivity), then copy/paste the files from your zip to the new project directory (thus replacingsrcandres` folders). That way, Eclipse will generate the manifest for you, with correct reference.
This should not take more than 30 seconds...
Go to Project Explorer and right click -> Import -> Select Android -> Existing Android Code Into Workspace -> browse to folder with your code -> finish
I encountered the same problem. I did thought that it's missing the AndroidManifest.xml file. I tried to fixed it and place it here. You can download it an try.

Categories

Resources