Sharing an Eclipse workspace between Linux and Windows - android

I've come to use Eclipse to develop for Android on my Windows machine for quite some time now, but more and more I've been booting up into my Ubuntu partition. I honestly love both operating systems as they both have their pros and cons, but I boot into each one randomly. Anyway, I have three partitions on my hard drive. One for Windows 8, one for Ubuntu, and one for shared data (docs, pics, videos). But I would like to seamlessly develop on one OS and then on the other. So, my data partition should be able to hold my workspace, but I don't know if that will ruin or corrupt the .metadata and potentially ruin my projects. Basically my question is... are there any tips or tricks with the Android SDK, AVD, ADT, workspace, or .metadata when using them between two OS's so that it works seamlessly?

In theory, you can use two different installations of Eclipse to manage one shared workspace. However, you could potentially run into problems if you aren't running exactly the same version on both sides (or, if you upgrade one side but not the other).
In practice, you are probably better off having separate workspaces on each OS, and then having a shared repository (using Git, for example) to share your code. Not only will that work better, but you'll be using source control too.

People have tried that before and run into trouble, so please go with the version control solution instead.
The drawback is that only the project contents are shared in the version control system. You will have two completely separate workspaces. So if you change workspace settings, they need to be changed twice (and don't even think about having .metadata under version control, that will have bad side effects).
Please be aware that several settings in Eclipse are available as workspace settings and also as project settings (e.g. the Java compiler version to be used). Make sure that you use the project settings and that you put the contents of the ".settings" sub directory in your projects under version control, because it contains these project settings. So they are in sync between your 2 machines.

I have been sharing workspace between linux and windows for quite some time and I only had minor hiccups.
Here are some of the things to keep in mind, if at all something has gone wrong, and you want to try some quick fix.
Initially you'll have to point the location of your sdk to the windows or linux path. This would be the first error that can crop up.
Try a clean build of the project(Project -> Clean -> Clean All Project -> Click OK)
Check Location Path of the project (Right Click Project -> Click on Resource). If it is loading from an ubuntu path (Eg: /home//Android_Projects), then you'll have to delete the project (Not from disk but from workspace) and import again.
Hope this helps.

Related

How to replicate this in Android studio from Intellij?

Intellij has the option 'import module from existing resources'.
Android studio seemingly only has 'New module' or 'import module'.
Here is the result of both of these.
I much more prefer the Intellij way as it is way more organized, since it allows you to basically have multiple projects open at once. The Android Studio way does let you have them both open, but they are not treated as separate projects and or libraries, but instead as a different folder.
Is there any way to do this, or at least replicate it?
Right click on the project space and select New->Module and import from existing source. Find the path of your other project. When importing, you may rename the app files to "app2" or something. See if that's what you want.
Remember that Android Studio is built off of IntelliJ Idea, so a lot of the settings are similar. Personally, depending on my projects, I like to have several windows open for different projects since it gets crowded but I can understand why you'd want them in the same project space.

Most rational and painless way to work on the same Eclipse Android project on two different PCs

I have a project that I develop partly at the work pc and party at my home PC.
Export-Import-Export-IMport and so on
And every day I spend a good amount of my time trying to resolve those annoying build path and configuration issues. Today I have written two lines of code and I have wasted the rest of my time dealing with all kinds of errors you could imagine.
And this hell repeats daily.
So I thought
Could I install Eslipse ADT on a flash drive and have my workspace on the flashdrive as well, so once the configuration is set up properly, I will be able to finally concentrate on development?
I could equalize the number of drives of both my PCs so the flash drive always appears as with same drive letter, if that could be an issue?
I really want to find a way to use the same IDE installation and the same workspace at two computers. Not two different IDE's.
Every time my project needs a new library I have to install it on both computers and it goes to a different directory and then I have to set the project to use it and when I switch computers all settings are wrong again.
This happens to me aswell. Your problem is that Android uses some external libraries, which on every computer, are located on a different directory.
Those libraries, are referenced in a file named project.properties.
All you've to do, is use a GIT or a SVN as a link to your home - work. And then, add several ignores, basically:
project.properties
bin
gen
This will kill any troubles.
In Eclipse, the project contents and the workspace are logically separate (although the default location when creating a project is place its contents in the workspace folder on disk, it doesn't have to be that way). Workspaces can not be shared between computers or users, but project contents should be. That includes all of the configuration files that make up a project (.project, .classpath, etc).
You could use a portable storage location like a flash drive or Dropbox to store just the project contents, and import it into each different Eclipse workspace you want to work on it in (ie, each different computer), but you'll need to always remember to Refresh the entire project every time you start to work in the workspace and there's a potential for human error to screw things up. I second the other recommendations to use some sort of source control system like cvs, svn, git, etc to check files in/out for working on different workspaces/PCs. I've done that many times with good results.
Why can't you just setup you favorite IDE once then export/import your settings to another PC?
That way you'll deal with IDE config issues.
Then configure Maven build for your project so all the dependencies and stuff can be resolved automatically during the build process.
And as last step you should setup git repo for the project - Github/Bitbucket, for example.
Leaving home => push all your daily work; came home => pull all updates and continue working.

How can I use ADT on both my Mac and Linux Dev Machines

I want to have the SDK available on both machines and sync the projects via Dropbox. However, since the SDKs for Linux and Mac are different, I have to chose a different SDK folder each time when launching Eclipse. Any workarounds?
I actually did something similar to this a while ago. I found that managing the ADT plugins (and SDKs) separately on each machine was a better solution, since they had path dependencies. I used Google Drive (Dropbox in your case) to hold all of the projects, which was ok at syncing the projects, but tends to run into issues with all the binary files created when building projects. As my projects grew larger, this became a bad solution for keeping things in sync as there were constantly syncing issues due to the amount of files that needed to stay in sync.
The best way to really do this is to use source control to keep your projects in sync, and I strongly recommend Git over CVS or SVN. GitHub offers free public repos and paid private repos while Bitbucket offers free public and private repos. I moved all of my projects to Bitbucket and now have them synced between machines, backed up, have stored histories, and can be shared publicly/privately (if I want).
In my opinion you should move away from using a file syncing service and use source control, it takes a little effort up front but is well worth it in the end.
Try syncing only the actual code files you create, not the project itself (i/e file1.java if you're writing in java, file2.cpp if in C++, etc). You might have to monkey around with adding new files, but that should be as simple as importing/exporting. You're going to have all kinds of trouble syncing paths for 2 different machines...
Otherwise try a free source control like assembla

How to use a Android Studio project on two computers?

I use two computer for coding. My desktop pc and the notebook. I sync the two computers with dropbox. How can I import/load a project on each of this two computers? The project base folder is different on each computer. When I try to load/import a project which is created on the other computer it loads the project but I got a error with a wrong path.
"Gradle "Test2Project" project refresh failed:
Could not fetch model of type "IdeaProject" using Gradle distribution "http://services.gradle.org/distributions/gradle-1.6.zip".
Project directory "C:\Users\thomas\AndroidStudioProjects\Test2Project" does not exist."
The wrong pfad is the right pfad on the other computer. How can I import Android Studio projects so that it works even on another computer with a different folder structure?
Like the others i agree, that using a VCS would be the best solution. Even though you can try to filter all android studio related files (like *.iml, .idea folder and local.properties). I don't know if you can do this with dropbox or if you need some kind of 3rd software.
After that you should be able to make source code changes on both computers without greater problems. (You may have to declare project dependencies changes for the android studio twice)
Builds depending on the build.gradle files should work to. But again: using a VCS is the better way to go.
Go for git, you can use bitbucket.com as a free remote repository.
This is a problem I have ran into when trying to store Android projects in a Dropbox folder. What happens is that Machine 1's IDE is mapping system resources (like the SDK) as being in that machine's filesystem. When you go to Machine 2, everything will work EXCEPT for what you expect--because the SDK will probably be in a different spot!
One way to get around this is to use your VCS (dropbox, git, whatever) as a repository for JUST your source files, and then have a local project created on each machine that reads from the Dropbox folder. This requires two separate projects that are mapped differently, but that have the same source folder.
I discovered this problem when I tried to load up an Android project on a new install on a Mac machine:
Do you see what's happening there? My Mac Android Studio is saying, "Hey, I don't see where "C:\Android\SDK is, but I do see that you have an Android SDK in a different folder, so I'm going to update your project files to reflect the actual location of the SDK."
In my opinion, the only way around this is to create your project on both machines, and version control your source and assets folder. If you don't create the project separately on each machine and use VCS for just the source and assets, the only way to get around build and filepath errors is to store your SDK in the same folder on each machine. This worked for me when I was building on a Windows desktop and Windows laptop, but no longer works for me since I am using a Macbook Pro.
I know this was questioned about 4 years ago, but this is up to now still an issue. Using a VCS seems like a good solution, but for me it is simply more overhead than i want to have. I also use Dropbox to synchronize my folders and the history they provide is for my private programming needs good enough. So i think, it would be good, if android studio simply uses relative paths.
I know it needs some system paths and it does a good job in looking at the local.properties and setting it to the correct place when the project is loaded.
The main problem with using Dropbox are the build-directories. There are many many references to fully qualified paths in the files within these directories. So my solution was to exclude the build-directories from Dropbox-synchronisation.
When you work at your laptop, build the app, create new files, change files or delete files, the build on your pc will be completely outdated when you switch back to it. but android studio will recognize this and do a fresh build when you start your project for the first time after working on the laptop.
so the biggest problem at this point is the file local.properties and this is handled correctly by android studio. it may be a good idea (or a really bad one, i don't know the drawbacks) when the build system wouldn't write fully qualified paths in the files within the build directory.
But up to now this is my solution for using Dropbox and not using a VCS:
exclude build-paths from Dropbox synchronisation
i hope this helps somebody.

Erros in trying to synchronize Eclipse workspace files across a Windows machine and an Ubuntu machine; which files must or must not be included?

I have been developing an Android app on a Windows machine. Now I would like to continue development on another Ubuntu 10.04 LTS machine. I would like to move between computers maintaining a recent copy of the project files on each computer. I am using SpiderOak to create a synchronization of the workspace directories of Eclipse which I am using for development. When the files were copied from the Windows machine onto the Ubuntu machine and I ran Eclipse, an error was presented that the path to the java sdk could not be validated and the path shown was the path relevant to the Windows machine.
Is there a simple solution to this? I can imagine that some files regarding the workspace specifics should not be transferred. Can I simply omit transferring the .metadata folder contained in each workspace created by Eclipse? I am not interested in synchronizing preferences/plugins/parts not essential to the operation of the app. Will excluding the .metadata from the sync create another problem in not transferring valuable information regarding the Android app being developed?
The correct, simplest, and most robust way to do what you want is to use a version control system like CVS, svn, git, etc. Even when working alone on a project, its a wise idea, not just for having the code on different computers but also because it gives you all the benefits of version management like being able to rollback changes, etc.
There are many free or inexpensive cvs, svn, and git hosting options; I strongly suggest you get an account and check your code in/out on the two machines you work on. If you have a web hosting provider, chances are they provide one of these services with your account.
If you're going to insist on manually moving/syncing code, you need to know that Eclipse workspaces are NOT designed or intended to be shared. Trying to do so always leads to headaches and other pain. Instead, you can export/import the project(s), not the workspace. Keep in mind that in Eclipse, a Project does not have to be located in the workspace directory; when you create a project there's an option to store it in any arbitrary location on your filesystem. Also note that all files under the project (including .project and .classpath) should be shared, except generated stuff like bin/ and gen/. This applies to using cvs, svn, etc or some other manual syncing mechanism.
As long as I have my project source code on hand, I will never consider synchronizing Eclipse workspace directory for cross-platform development. The correct way is maintain your source separately (by separately, I means do not bind your source to any IDE on any OS, use version control system is always recommended if the condition allows), wherever your want to start development by Eclipse or IntelliJ, on Windows, Linux or Mac, get a copy of you source and import it into your IDE.
Generally, the only files that makes your project a Android Project are:
src/
res/
assets/
lib/ (if you import external jar libraries)
AndroidManifest.xml
project.properties (or default.properties, renamed since r14)
proguard.cfg (if you use Proguard)
If you work within a team and use source control like SVN, these are the only required folders/files that need checked in to SVN, all others (.project, .classpath, .settings/, bin/, target/ and etc.) are not necessary. thoese are iteratively generated by IDE when import and build your project.
This applies to all three Android project type (Android Project, Libaray Project and Test Project), If you are familiar with other build tools like Ant or Maven, it may also helps you a lot to maintain cross-platform development.

Categories

Resources