How to use a Android Studio project on two computers? - android

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.

Related

Sharing project folder in Android Studio

How can I share a project/working directory between two Android Studio installation in two different computers? The shared repository is a file sharing cloud service like Dropbox.com or box.net.
The reason I want to do this is that I have a desktop and a laptop each with Android Studio. I want to be able to seamlessly do development work between the two systems without having to checkin or checkout code in a code repository.
I don't plan to run the two Android Studio concurrently. This is just for me - one user.
I used to be able to do this with Eclipse ADT but with Android Studio I am getting multiple errors - missing libraries, etc.
Any suggestions on this use case is also welcome.
Thanks in advance,
Ray
It is actually working, to begin with. It was an oversight on my part. I needed to download the latest version of Android Studio (including the updates). Since applying updates I can open the project in another device by referencing the project working folder in the shared folder (in this case Box.net). I just get an initial prompt on the SDK location, that it is unable to find the original location. But it did offer to use the SDK location on the current computer.
When using the current device's SDK folder it will say that it will "modify the project's local.properties file." I click OK on this and it's all good.
This is what I wanted to do. But I'm looking at GitHub now. Thanks.

How to use Egit with BitBucket to sync a project across two computers, this project needs to use ActionBarSherlock

I've read and read and I'm still confused on the concept as described in the title: how do I maintain sync'd code between two computers, using Egit w/ BitBucket, when an Android library project like ActionBarSherlock is required?
I guess things got complicated for me when I started thinking about Eclipse workspaces vs. local git files. I am now very confused on the most efficient way to be syncing between two computers. I am able to do it now, but it's very cumbersome and ALWAYS the project-properties is incorrect about the path to the ActionBarSherlock library.
TL;DR - This being said, what is the high level concept for easily pushing and pulling code from BitBucket without dependencies getting broken in the process?
Also, should I have a full copy of my project in my workspace AND in the local git directories? I believe I should as one mirrors the other? Or should I only have 1 physical set of files, in the local git directories, which is logically referenced to from Eclipse (as opposed to having the physical files copied to the workspace itself).
Thank you for clearing this up,
Ryan
Figured it out: Here's what you do. Set up the development environment to use the same workspace path on both development machines. I switched mine to 'C:\Development\Android\workspace'.
Next, I imported ActionBarSherlock into the workspace I just created (make sure you copy the files into the workspace), do this on both development computers.
Now, ensure the path to the local Git files is the same on both machines, it needs to be the same as the path to your library project will be relative, and not fixed (../../ instead of C:/...). In this case, I'm using 'C:/Development/Git' for the local Git directory.
Next, import the Git project by cloning it from URI using the BitBucket URL for the project you set up. Right click on the project you just cloned, select Properties > Android, at the bottom of the Android tab, add ActionBarSherlock as a new library.
Commit and push the changes to the project.properties file. Voila! If both computers use the same paths, your library project will work as it should when updating your Gits!

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.

Sharing an Eclipse workspace between Linux and Windows

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.

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