Migrating SVN to Android Studio - android

I'm migrating my Android project from Eclipse to Android Studio. I use Subversion and am wondering how I can migrate my SVN to the new file structure used in Android Studio without losing my history.
Thanks for any help!

Posting this because it might help someone else.
I ran into the same problem as well. #user714965 was inspiring but didn't solve my problem because I couldn't figure out how to get SVN recognize that I moved a file from the original folder to the new structure in my working copy.
For the following, you will need TortoiseSVN or a similar SVN GUI client to do this.
Here is what I did:
Commit the Eclipse project last changes into the SVN repo.
Open Android Studio and use that to import the Eclipse project working copy.
Android Studio will nicely convert the Eclipse project into a Android Studio/Gradle project. Let's call this project "PrjGradle".
Open the converted Gradle project folder window and keep it one side of your screen
Go into your SVN repo where you have your project (using TortoiseSVN).
Backup your current trunk into a branch or a tag and call it "final_eclipse" or whatever.
Now, mirror the folder structure of the newly converted Gradle project on your local machine directly on the TortoiseSVN Repo Browser window. Meaning, look at how the directory is structured in "PrkGradle" and create/delete/rename folders directly on the trunk repository. This will be painstakingly tedious but you have to bear with it if you want to preserve your SVN history.
When you move files around (not copy) directly on the repo, the history of the files remain intact.
Once you complete, check out the restructured directory into your local machine. Let's call this "NewPrj".
Use a suitable Folder compare program (such as Beyond Compare) to synchronize missing items (such as build.gradle, .iml files, etc.)
Rename your converted project to "PrjGradle_old", and rename the newly checked out project (NewPrj) to "PrjGradle".
Open "PrjGradle" in Android Studio. That's it!
Hope it works out.

I don't know the differences of both file structures. But it would try it this way:
Check out your project (maybe better use a client like TortoiseSVN)
Build the new file structure (new folders)
Commit
Move the files from the old structure to the new
Commit (check the commit dialog if there are move actions only!)
Delete old folders which you don't need anymore
Commit
SVN will recognize these move operations. You will see if it works by the operations in the commit dialog. If there are "delete"/"new" actions something went wrong there should only be "move" actions.

Related

How to add android studio project in same repo on github

When I uploaded a project on github, it automatically created a new repo with the project name. Now, I want to add another project on my repo. The thing is I want all of my android projects on the same repo. How do I do this?
The new project I want to add is throwing me error like "remote with selected name already exists".
The github error when trying to push.
EDIT:
Now when I created a folder in my system and tried uploaded it using this link, some of my projects aren't opening.
What's this? Any help is widely appreciated!!!
Right way todo this. follow these sample steps or you can add it manually
Check out git repo and open it in Android Studio.
Choose Import Module from File > New
Copy your project folder path and past into source directory: click finish that you want to add in existing repo. This will allow you to switch between projects right from Android Studio.
Commit and push your code.
Note: Make sure you don't have app with same name. by default it says app
You cannot upload all projects on the same repo. You have to do it manually.
or you can make a folder and then place all your projects inside it.
You can't create two repositories with the same name. If you want to put all your projects in same repository, you could either create separate directories under same git or , you could create separate branches.

How to upload an Android studio project to Subversion for first time

I have a local project on disk and I'd like to upload it to subversion for first time. We usually use TortoiseSVN (or subeclipse plugin back in the day), but now we'd like to do it directly from Android Studio.
My local project is:
C:\\ParentDir\ProjectDir
Inside that folder there are the usual directories: .gradle, .idea, app, etc.
Id like to upload it to a repo I've just created in the svn server:
svn://serverip/parentdir
The final repo folder structure should look like this:
svn://serverip/parentdir/ProjectDir/branches
svn://serverip/parentdir/ProjectDir/tags
svn://serverip/parentdir/ProjectDir/trunk
I can upload the project successfully by manually creating the ProjectDir/trunk folder in the svn repository and then selecting "VCS -> Import into version control -> Import into subversion". (BTW, what a confusing name, it should have been called "export to version control" instead). But then the project remains unversioned. Apparently this operation is meant to upload only once with or without version control enabled.
So next thing I tried was "VCS -> Import into version control -> Share project (subversion)". This creates the ProjectDir folder in the server, and also the trunk, tags and branches subfolders. The project is correctly uploaded but it gives me an error at the end:
*C:\\ParentDir is not a working copy*
After this, every file in the project appears as unversioned (red), and the changelist is empty even after changing some files.
It does not make sense to me that after enabling VCS for the whole project I need to manually add every file or folder one by one. Something must have gone wrong due to this error.
What could be the problem? Is there a safe sequence of operations to upload a project for first time?
The solution was to use "VCS -> Import into version control -> Share project (subversion)" and select 1.6 format in the dialog. I was using 1.7 format at first and it didn't work.

How to push Eclipse project to Github

I'm new to Git and Github and I'm trying to figure out how to push to the root directory on Github from Eclipse (Windows).
I have created a Github project called MyProject. MyProject is an Android project with the usual Android directory structure:
MyProject
src (+ res, assets, etc)
From Eclipse I push my Android project called MyGame to MyProject. MyProject now becomes a sub-directory to MyGame, so that the readme file in MyProject isn't visible unless the user first clicks on MyProject on Github to drill down one level in the directory hierarchy.
How can I push MyGame so that its contents (src folder, res folder, readme) become visible at the root level in the Github project.
Update: I tried using command line:
git remote add origin git#github.com:username/reponame.git
git push origin master
This has the same result, on Github the directory hierarchy is:
MyProject
MyGame
src
How can I make it
MyProject
src
?
I believe your problem may be that your git repo in Eclipse is in the parent folder of the project. What you need is for your git repo to be in the project folder.
Now, Eclipse seems to recommend that Git repos be set up in the parent folder of their projects. I am guessing that this is so that later related projects that may be needed can be easily added to the git repo. If you're not worried about that, and just want it to work as you described, see below.
Note that I'm running Ubuntu Linux, and so my Eclipse and desktop will probably look different from yours.
First we're going to find out if my guess as to the problem is correct:
Open the "Git Repository Exploring" perspective in Eclipse.
Look at the "Git Repositories" view. See if the path given for your repository is pointing to the folder containing your project. If it is, continue with the instructions below.
If your repo is in the folder above your project, then the problem shapes up like this: Git will recreate all the paths in your repo relative to the repository itself when you push it to GitHub. If it is in the folder above your project, then all the paths will include the folder containing your project. So, you'll need to move your repo into the folder containing your project. I'll describe the steps to achieve that below.
To begin, you'll want to make sure you don't have any uncommitted changes, or any stashed changes (if you don't know what stashed changes are, don't worry about them).
As a matter of caution, you may want to create a complete copy of your current code & repository at this point if it's at all important.
Open Windows Explorer and navigate to the folder containing your git repo, per the path given in the "Git Repositories" view.
At this point, you may want to close Eclipse, to avoid changes startling it (they shouldn't, but "you never can tell with bees!")
If you can see a .git folder in Windows Explorer, then go on to the next step. If not, you'll need to show hidden files. http://windows.microsoft.com/en-US/windows7/show-hidden-files gives instructions for Win7.
Now you should be able to see a .git folder. Copy this into your project folder.
Start Eclipse (if you closed it) and open the "Git Repositories" view again.
Click the button to add an existing local git repository. Choose the project folder.
Go back to the normal Eclipse Java perspective. Right-click your project and choose Team > Disconnect to temporarily stop heeding the old repository.
Right-click on the project again and choose Team > Share Project.... When prompted for a repository, check the box to use the one in the project/parent folder. In the view below, check the box of the one which is directly within the project folder (it will probably have one dot next to a folder.) Then click the Finish button.
Now you'll probably have a lot of catching up to do. Git will believe that you have deleted every file in your project and replaced it with a file with one less layer of directory path. You'll need to commit all those changes to get a clean repo.
Push the changes from step ten to GitHub. Check that it looks as you expect.
I hope this helps. Please comment if something's unclear or there's another issue. Please make sure to have a backup before you try this... I've not tested it entirely, and I don't want to cause any unneeded grief.

How to create new android project in eclipse and share in local git repository?

I use the wizard to create a new Android project in Eclipse Juno with Android SDK Tools revision 20.0.3 at build SDK 15 and minimum required SDK 15. The files are generated with sample code for activity, manifest, etc. I have tried different templates (like MasterDetail or BlankActivity with Tabs) in this process and there are sometimes issues such as AndroidManifest.xml or activity_main.xml with repeated XML elements. So I fix these issues manually (which I think is a bug with the wizard).
Now, I want to "team share" the project via EGIT. So I right-click the project and "Team->Share Project->git". At this point, it wants me to choose a repository. I have created a new one outside Eclipse workspace (and re-used it once created). (I also tried creating one in the parent directory (i.e. in workspace despite an Eclipse warning not to do so).
Either way, when the share operation completes, the buildpath for Libraries "Android Dependencies" does not have the "android-support-v4.jar" in the location specified which was in the workspace. It seems that after the egit operation, the project directory appears to have been moved to the repository, but the .classpath file has not changed.
Is this how egit should work (move project workspace inside git repo and tell Eclipse that the project directory is in a new location)? Is the only workaround to fix the buildpath manually?
Is there a different approach to create new android project in Eclipse and then put the relevant files (i.e. exclude generated java files) into a local git repository such that Eclipse EGIT works?
I am answering my own question after some trial and error.
Here are the steps.
Create the android project via the wizard.
Fix any XML errors (as necessary) to get a buildable project.
Right-click project and Team->Share Project->Git
Select the Git Repository (and create if necessary).
At this point, the Android Dependencies (a dynamic classpath container) in the Java Build Path will be wrong because Git has moved the files to the repository.
Close the project (Project->Close Project)
Re-open project (Project->Open Project)
Now, the Android Dependencies are correct because it is dynamic. I don't know the exact mechanism used by Eclipse for dynamic classpath container, but if you read the Android Tools website it will explain the rules used to to populate this container.
Clean the project. (Project->Clean...)
The important thing is not to try to fix these Android Dependencies yourself (like deleting it), because then your Android project may have issues when you start to build the APK.

Copy and past a app?

I finished a "base app" for all my next apps in eclipse, with admob, contact us...
Can i sort of import this project in a new app and work from there? Or just copy and paste everything and just change the name? How? Like just start a new app with every thing like that app and the work it out from there?
thanks
You can turn your base app into a Library project (see http://www.vogella.com/blog/2011/03/03/android-library-projects/) and your other apps will include this library.
One gotcha with this is that the AndroidManifest.xml from your library is ignored, so you may need to manually copy activities, services, etc. from your library manifest to the real manifest.
I would put my "base app" project in a code repository (git in my case), and then just clone it, change the output name, libs etc in any build scripts. Check that into a new repository and keep working from there.
If you don't use git/svn/whatever just copy your source files and create a new project in eclipse, it's probably easier and less error prone than copying the project files as well and trying to remember all the places that refer to your old project.
Might be a little off-topic but what I usually do is I have pure source (and some build scripts) in a code repository and then outside that (in my eclipse workspace) I create the eclipse project and link the source files into my project. So if I trigger builds with eclipse I get the build output in my project directory while keeping my source directory clean.

Categories

Resources