Git and Android Studio nightmare Version Control - android

Yes i'm new in git, but as far as i can see it's a pain.
Assuming that:
I'm working on Windows 7 64 bit
Git perfectly installed
Using an Assembla repo which i'm currently using with Eclipse and SVN
I'm now developing with the absolute latest version of Android Studio (updated just 2 days ago...)
I want to ask here, if is my lack of expertise, or it's simply inferior to SVN (which also gives me a bunch of problems in Android Studio, when in Eclipse i can work like a charm!).
This is what i've done:
- made a project and decide to add to Version Control
- went in project dir and get Bash console.
- "git init" and there aren't all the files under git control because of this ignore list (why and how git decides alone that there are things to ignore here, is a mistery, if someone could explain that would be awesome.)
- Deleted ".ignoregit" file list and give a "git add ."
- now it seems everything's under VC but if when i drilled down in project tree i've found for example "build" folder not checked with git sign icon.
Tried every command like "add -f" and "add *" and such, no way.
Sometimes it seems fooling me around adding something that wasn't added before, but remove something else from the list of versione files!
Really really inexplicable.
Thanks

If you're going to use git I recommend you go through this quick tutorial http://www.gitimmersion.com. It takes about 2 hours all-in, but you'll have a strong foundation in git when you're done.

why and how git decides alone that there are things to ignore here
The gitignore files are not created by git but I asume by Android studio and they do make sense. You can still decide to delete them.
You probably have 2 gitignore files, one in the project folder, one in the app module folder.
After deleting them both, all files should be added.

Related

Strange automatic commits (Android Studio, GitKraken, Ubuntu)?

I'm working on an Android project for my company.
Here is my current development setup:
Android Studio (version 2.3)
GitKraken (version 2.1.0)
Ubuntu (version 16.04)
As I make improvements to my project in Android Studio, I use GitKraken to review my changes and commit them to GitHub. Nothing out of the ordinary.
My problem is that every once in awhile, files will be committed directly to my 'master' branch and pushed directly to GitHub - without me doing anything. The files that are pushed are configuration .xml files that I haven't changed. This is very frustrating, for obvious reasons. The commit message that is generated usually looks like:
AI-2.3 trent#trent-Lenovo-Yoga-3-14 Create hg.xml
I have deleted my 'master' branch completely (local and GitHub), and created a new branch called 'stable' to take it's place. That didn't work, as these 'auto commits' simply create 'master' branch again and push it to GitHub.
I have also turned off VCS settings in Android Studio. I cannot find any setting in GitKraken would be doing this - to my knowledge, anyway.
I'm hoping that I'm unaware of a simple setting that can stop this behavior. I've searched for similar issues on Google, Android Studio forums, and Stack Overflow, with no luck.
Please let me know if you have any questions.
Got the same problem with Android Studio 2.3.3 and Ubuntu 16.04.
The problem occurred after Android Studio (AS) glitch when it lost my private IDE settings.
Solution: look into dir ~/.AndroidStudio2.3/config/settingsRepository (take notes that .AndroidStudio2.3 is hidden dir). In my case, there is repository dir that contains my Project plus all that wired additional setting files that been added to my GitHub master branch every time I've Push. Just delete that repository dir.
Looks like AS use its own source control system on top of Git. As I can see some people even use it for backing up their settings:
https://github.com/kakkoyun/android-studio-settings
https://github.com/xinthink/android-studio-settings
Didn't go dip into the problem, just solve it for my case. Would be good if any Expert explain that strange Android Studio behavior in more details.
Also related to Android Studio keeps adding additional files to GitHub

How do I handle .gitignore in Android Studio?

To start, excuse my noob-ness as I'm pretty new.
I want to be able to work on an Android project between my desktop and laptop computers, but I'm having an issue with figuring out how to push and pull the files between computers.
I suppose one of my largest issues is I really don't understand gradle. But it seems to always be very important, and extremely fragile, cause it breaks everything any time I update something, or to import a project.
I set up my project with VCS, and it seemed to auto-generate a .gitignore with the necessary things, but when I pushed it to github through Android Studio it seemed to just push everything in the gitignore anyway.
I thought maybe this wouldn't matter, and tried to import the project onto my other machine, but it blew up anyway and told me it was missing modules or something. I'd try to fix this manually but I'd rather figure out how to just make the gitignore work properly. Should I not use the Android Studio VCS and just manually push and pull through bash, or is there something I'm missing?
I can't figure out if my issue is with the export of it to git/Github, or with the pull on my new machine, not having something configured properly.
If it helps, my project is at:
https://github.com/Ashanmaril/Quotr
If someone can tell me what I'm doing wrong, I'd appreciate it.
I think you mean that you pushed .idea folder to github, you should edit .gitignore to have line /.idea/ or just .idea/, you will have to remove .idea folder manually by:
git rm --cached -r .idea
git commit -am 'Removed .idea folder'
git push origin master
The folder with idea config will not be deleted from your disk, only from repo.

Getting GoogleCast to work

I've tried, with zero success so far, to both create a new project and add GoogleCast to it and to get the given examples to work on Android Studio (currently using 0.3.2, but will upgrade if needed) on MacOSX.
Migrating to Eclipse, however, is not a valid option at this time.
I always seem to end up stuck with some reference issue, either giving me the error "No resource found that matches the given name '#style/Theme.AppCompat'." or multiple compile-time errors related to having no idea where android.support.v7 is located at.
Tried many different solutions, such as removing the #style part that someone mentioned to work or setting the v7 path as relative.
Though I wasn't able to follow through with this last one, no idea how to actively do that in AS and not enough reputation to comment there.
Then I came up to this solution Anyone get the chromecast android examples working in android studio?, which seems like a good attempt, except I can't seem to find the mentioned GoogleCastSdkAndroid.jar anywhere, so I'm stuck.
Couldn't find a truly comprehensive tutorial anywhere either, since they all seem to have no issues whatsoever adding v7 to the project.
Thanks in advance for anyone who can donate some of their time to solving this issue.
EDIT:
After upgrading to 0.4.6 (is 0.5.1 stable already? Considered how fast it came after 0.5.0...doesn't sound too good); I did what Ali Naddaf suggested, but couple extra questions popped up:
I could build the CastVideos project and import it into Studio with no problem; however, the CastVideos project structure is radically different from a new project's structure (referred to as OtherApp from now on).
The main issue that pops up when I try to mimic CastVideos on OtherApp is that it doesn't find the CastCompanionLibrary project on the OtherApp only, which I can't seem to be able to figure out where exactly should be located at (I thought the 'core' folder was the one with AndroidManifest?).
Also, how do you import modules now? The Project Structure only allows the creation of new modules.
My suggestions:
update your Android Studio
open SDK manager and make sure you have the "Android Support Repository" installed
create an empty directory on your system (referred to it as <DIR> below)
change directory to <DIR> and clone CastCompanionLibrary-android to CastConpanionLibrary
$ cd <DIR>
$ git clone https://github.com/googlecast/CastCompanionLibrary-android.git CastCompanionLibrary
$ git clone https://github.com/googlecast/CastVideos-android.git CastVideos
first make sure all is fine by building from command line:
$ cd CastVideos
$ ./gradlew build
it should do a successful build at this point.
if all is fine, open your Android Studio and select "Import Project" and point to build.gradle in the CastVideos project.
Now for any other project, you can look at the build.gradle in CastCompanionLibrary or CastVideos to see how you can set up your dependencies on the support libraries; if you don't have dependency on the CastCompnionLibrary, then it is even easier.
You very much need to upgrade Android Studio. 0.3.2 is quite old and a multitude of bugs have been fixed since then that are almost certainly affecting you.
Other than that, make sure you have the Android Support Repository installed in your SDK Manager. Between those two it should solve your support.v7 errors and #style/Theme.AppCompat issues.
This question is very old but to make it work I had to clone both Git repositories (CastCompanionLibrary & CastVideos-android). Import CCL into Android Studio as Non Android Studio Project, change the version of build tools to current 21.1.10, build the project and close it. Android Studio asked me to reopen the project. Hit yes. Do exactly the same with CastVideos-android and finally I could launch it into my smartphone.
Was really painful, took me 2 hours make sense of the error, because I was trying to open into Android Studio like Android Studio projects (they were) but there was a problem with the .idea file.
Tried this and everything worked.

Can't checkout an android project in STS 2.9.1 and Subversive on Windows 7

The problem
I have a strange problem with SpringSource Tool Suite 2.9.1 Release and Subversive plugin, running on Windows 7 Home Premium x64. I'm trying to checkout an android project from an SVN repository.
Here's what I'm doing:
File > Import > SVN > Project From SVN
I fill in the path to my repository and check the HEAD revision
I click Finish
The project is found and the default option is Check out as a project with the name specified. I leave the name alone Set the Depth field to Recursively and again, select the HEAD revision.
I click Finish
A progress bar appears for a second just to show an error message:
Checkout operation for 'https://(.....)/Android' failed.
svn: Cannot create new file 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn\lock': System can not find the path specified
When I retry and follow the steps from 1 to 6, another dialog appears. It says:
This project already exists in the workspace
or there is a data folder in the checkout destination.
It allows me to select a folder to overwrite. When I do that, a similar but different error message is shown. It says:
Checkout operation for 'https://(...)/Android' failed.
0x0000000f: The folder 'C:\workspace-sts-2.9.1.RELEASE\AppName \.svn' is locked by some external process. Please unlock the folder and try to check out the project again.
What I've tried
First, I opened the SVN Lock view to see if there were any locks created by the IDE. There were none.
I restarted the computer, hoping it would solve the problem of any application locking the file but this does not seem to be the case.
After that, I created a new workspace in a different location and tried to check out the project in there. The result was the same.
Then, I attempted to change the version of SVN Kit. The situation persists in:
SVN Kit 1.2.3
SVN Kit 1.3.5
Native Java HL 1.5.4
Native Java HL 1.6.12
I thought that changing permissions to the directories of my workspace was worth giving a try. It didn't do the trick either.
Finally, I checked out the project in a different location, using Tortoise SVN and imported it into my workspace. I could run it (though some build path settings seemed to be missing) but it's not a solution. I can't possibly imagine working on the project simultaneously with a couple of people without the ability to commit/update/view history/resolve conflicts in my IDE.
I was advised to install a separate version of eclipse with its own set of tools and a different workspace for this application alone but it doesn't seem like a good idea. I'd like to keep it all in a single IDE. I'd also prefer to avoid reinstalling the whole thing as I don't feel like configuring all the other tools (mostly spring and android-related) from scratch.
Has anybody seen a situation like this? How can I get it working?
It's uncear to me whether this is a subversive problem or an SVN problem. I would try checking out from the command line (you must install SVN command line tools to do this, but I'd recommend having the tools around as a backup anyway).
Checkout from the command line and then import into STS using File -> Import -> Existing projects into workspace. Once in the workspace, you can select the project -> Team -> Share project to get svn support on it.
Rename the project and check out again , It must be a problem where u are trying to checkout the project which already exists with same name in the Package Explorer

How install old ADT13 in Eclipse

We do have lots of problems with our Android Apps when using SDK14/ADT14. Currently we can't build none of our complex apps with lots of libraries and dependant projects (Resources are not updated even after Clean, Refresh, Forced Save, ...). We would like to go back to SDK13/ADT13.
SDK13 is in our backup repository. But we don't have the ADT13 plugins.
How can we direct Eclipse to download the old ADT13 plugins?
Many thanks in advance.
I had to do this recently as well. Fortunately there's a hidden cache of old ADT versions, here's the link for the previous ADT release:
http://dl.google.com/android/ADT-12.0.0.zip
Then inside Eclipse you go to Help -> Install new software -> Add... -> Archive ... -> choose the downloaded zip. FYI: Unfortunately, you can't (or at least, I couldn't) revert to the previous SDK Manager and Tools version so easily (it insisted on getting itself upgraded before downloading the SDKs), I had to use an old copy of the folder I had lying around. Since you have SDK13 in your repo, you should be good to go.
You need to make sure that you've updated both the SDK AND the ADT plugin in Eclipse - I forgot to do the latter and had the problems you've described.
SDK14/ADT14 introduced a lot of changes - the old ADT won't work with the new SDK and the new ADT doesn't work with the old SDK.
If you've done both and it's still not working then moyshe's link takes you to the relevant to stuff to download (just uninstall what you have already and install the older versions)
Is your issue similar to this: http://code.google.com/p/android/issues/detail?id=21201
Basically each time I open Eclipse, I have to remove all library projects from all projects using them, apply changes. Then re-add them manually. Then I can start working!
It's very probable that it's related to http://code.google.com/p/android/issues/detail?id=21031.
This is serious issues and I can't believe no-one from Google has responded yet!
I'm posting this separate answer because of stuff I've learned from the Google Groups threads and my own experiments. I realise it's not a straight answer to the OP's question but I think it's useful here regardless.
ADT14 has changed how Android Libraries are handled in Eclipse. Instead of importing sourcecode (in LIBRARYNAME_SRC folders) it now compiles and brings over .JAR files (in a "Library Projects" folder).
To get my stuff working I built a complete new environment, installed the latest Eclipse/ADT/SDK, Imported my work and worked through all my projects from non-dependant libraries upwards - doing the following.
1 - remove all Android Libraries and 'Apply'
2 - remove all xxx_SRC folders from the Build-Path->Source tab
3 - remove any remaining xxx_SRC folders (should be empty anyway) from your Project.
4 - Add your Android Libraries back in again.
Another relates to Build Path Projects (non-Android ones). Before, ADT did not mind if you had the same Build Path Project in multiple libraries - but it sure-as-hell does now!! It crashes with "UNEXPECTED TOP LEVEL EXCEPTION"s, "java.lang.IllegalArgumentException: already added: Lcom/yourlibrarypath" and "Conversion to Dalvik Format Failed" messages.
This prevents you deploying - to solve it, go through your libraries and ensure that Projects only appear on the Build Path ONCE. I suspect that, previously, ADT actually may have need them duplicated and may even have created this duplication!?
Lastly, you have to ensure that Eclipse builds everything in the right order. Again, this didn't matter before but it's why your projects fail if you 'clean' or change anything. To do this you have 2 choices
1 - rename your projects so that they appear in alphabetical order from 'leaf' to 'root' (e.g. libraries < projects which use them).
2 - In Eclipse, use Windows->Preferences->General->Workspace->Build Order and specify all your libraries, in order. Anything not in that list is built afterwards so only libraries need be mentioned there.
Hope this helps someone

Categories

Resources