Problems keeping Git history after migrating from Eclipse to Android Studio - eclipse

I want to migrate from Eclipse to Android Studio. The import works fine, but the file structure is different after import.
I followed the steps in this thread, and copied the .git directory in the root of the newly imported Android-Studio project. But git does not seem to recognize my "moved" source files but lists them as deleted and also as new files.
Old structure:
MyApp
|--src
|--com.myapp
New structure:
NewApp
|--_myApp
|--src
|--main
|--java
|--com.myapp
Is there any I can tell git to find my files without manually doing it?

Thank you, Sebastien Dawans, this was indeed the missing link. After adding with git add -u, git recognized some of my files as renamed. I wonder why not all files. Android Studio seems to touch some files while importing, which causes git to have problems identifying them. So I copied the com.myapp folder containing the java files from my eclipse folders to Android Studio folder replacing the imported files. Same with the res directory. Than git add . and git add -u
That seems to fix the issue.

Related

Why .has .vscode folder been generated in my GitHub repo?

So, I started my Flutter project with VScode but later I completed the whole project from Android Studio and have now pushed it from Android Studio into my Github repo. In my GitHub repo, the .vscode folder (refer to the snapshot added) has been generated. Is this something I should be worried about and try removing it? I'm a newbie at Flutter and so kind of too meticulous about my codes. (^-^;)
No that's normal and automatically generated by vsCode
If it bothers you can simply ignore it using .gitignore in your project folder.

ignoring the build folder in an eclipse project in git repo

I am using eclipse java as an editor and would like to use the .gitignore to exclude the build folder for the project. This is what I have currently written in my .gitignore. The syntax seems to be right; I used the git documentation but I may have interpreted it wrong.
#ignoring the files within the build folder
/build/
build/**
I'm using a brand new repo so I shouldn't have any problems with already logged files in the repo.
I am trying to get git to ignore the build folder in the project file using a .gitignore. The ignore file didn't work. What could be a solution?
The way the .gitignore is written, this file needs to be in the same subfolder as the build folder, the file being ignored.

Java files are not being pushed to github

Android studio is not pushing java files to github. I found that it only pushed the src folder with the res (layouts and xml docs) folder. I tried adding the java folder to it (right click, add, then commit directory, and push), but it still does not push the java files to git.
Used this setup:
https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/
.gitignore:
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
When I right click on the Main folder (which holds the java files) and select commit directory, I get the following error:
Error:On branch master
nothing to commit, working directory clean
during executing git commit --only -F C:\Users\mmm\AppData\Local\Temp\git-commit-msg-999645.txt -- MainActivity.java
Did it through gitbash following the instructions here:
https://help.github.com/articles/adding-a-file-to-a-repository-from-the-command-line/
Right clicked on the main folder (containing the java files) and selected gitbash.
I ran into this issue recently. If your .gitignore looks good, you may want to check Git (local git repository) first and see if the .java files show up there.
The folder (/apps/src/main/java/myproject/bleh) where .java files were stored was flagged as "* Git Repository (subproject)" by Git and that was a consequence of a hidden .git file stored there.
Fixed it by deleting that .git file and adding the files to the repository.

How to include a git submodule into a project?

So I have a git repository for a few related Java classes with a folder structure similar to this:
mylib/LICENSE
mylib/README
mylib/src/file1.java
mylib/src/file2.java
mylib/test/tester.java
...
Now, I'm creating an Android app in Eclipse with the traditional folder structure like:
repo/AndroidManifest.xml
repo/bin/*****
repo/res/*****
repo/src/com/mysite/project/activity1.java
...
Now, I'd like to add the java classes to my android project in the folder:
repo/src/com/mysite/mylib/file1.java
However, if I add it as a git submodule, they are saved to the path:
repo/src/com/mysite/mylib/src/file1.java
Also, included is the tester.java, and some other files I don't want in the Android project.
What is the best way to resolve this? Should I just leave the path as com/mysite/mylib/src/file1.java? Or should I modify the repo and move the files from mylib/src up into mylib and delete the files I don't want?
The simplest way would be to:
keep your original (non-Android) repo separate
add that original repo 'src' folder as a source folder of your Android Eclipse project (an Eclipse project can defined several src folders, from various origin)
That will sidestep the "submodule" issue entirely, and allow you to select from your original project only the files you need for your Eclipse Android project.

Opening existing project from source control

I've been pushing my source to a Mercurial repository. Today I needed to delete my local copy and re-clone. I did this by simply moving my local copy somewhere else (just in case) and typing "hg clone url".
This part has worked just fine.
However, when I try to pull the newly cloned local copy into Eclipse, I get the following error:
/Users/Andrew/Dev/Workspace/Android/MyProject overlaps the location of another project: 'MyProject'
My guess is that I have been committing some meta file or something that I shouldn't have. Does anyone have any ideas? Here is my .hgignore:
syntax: regexp
\.DS_Store
.swo
.swp
.metadata/
/bin/
Note: Looks like my hgignore is not blocking the gen folder. Could this be part of the problem?
There is a bug in Eclipse what won't let you create an Android project from existing sources:
http://code.google.com/p/android/issues/detail?id=8431
You have to move MyProject to a folder that doesn't have any other projects in its sub-directories. You can then make a new project from existing source with MyProject. Remove the new project from the workspace without deleting the contents on disk and move it back to your Android folder. Now do an Import -> General -> Existing Project into Workspace, and MyProject should be available to import.
This is the only way I've been able to do it.
Ok, I'll try to sum it up, after I faced similar problems and wasted some time:
Eclipse Juno /4.2 SR1
(however I think it is a general misunderstanding of how eclipse imports projects)
If you want your new project "connected" to git/mercurial, you'll have to clone and import via "Import/Git/Import from Git"
It will fail if your "workspace dir" equals the "local destination dir".
A git clone via egit MUST NOT be placed! in the "eclipse workspace dir"!
The project import will fail because the projectname in the cloned ".project file" already exists in the eclipse workspace dir when the import occurs.
I think the problem is that you moved your local copy away and then you try to add another project into Eclipse at the same location as what you had before and you are just confusing Eclipse...
I would recommend to try to use command line commands for Mercurial and when you get into Eclipse, first clean up existing projects before adding another one.
My sollution was just to import as general project not an android one.
I ran into this problem when trying to import a git repo project and it's submodules. I ended up using import -> git -> Projects from Git (git plugin). This understood the concept of a project within a project just fine. The project is now monitored by that plugin. It's a good enough tradeoff for me.