Cloning AS Project Gradle Error - android

I'm trying to clone my remote repository for the first time.
I usually work on a desktop, but need to work on a laptop for the time being.
I know that I must have not included the proper gradle files in my pushes. I'm just trying to figure out exactly what I did wrong and find a way to fix it.
I won't be able to get back to my normal workstation until the weekend.
A link to my project on github here
After AS asks me to import project from VCS, it asks to create project from existing files or an external model. I've tried both, but I think the existing files option is what I'm supposed to do. After choosing that, I get the "Migrate Project to Gradle? This project does not use the gradle build....".
I've found quite a few posts about this topic, but none of them seem to be exactly what I'm going through.

It looks like a bunch of files are missing in the root of the project. Normally there is a master build.gradle at the same level as app that directs the build. This project doesn't have one.
What I would do is create a new project from scratch in a different space and copy its build.gradle, gradlew, gradle.bat, settings.gradle, and .gradle directory into a clean clone of your project and try again, choosing the root of your project as the import location.
I don't 100% guarantee this will work as there may have been modifications made to any of those file that may have been lost, but this should bootstrap your project again.
Also make sure a .gitignore isn't somehow ignoring these files so you can commit them back to your project. They really do need to live in source control.

Related

Android Studio integration with GitHub failing to upload project files apart from MainActivity.java

I have recently created a new Android application and have used its VCS to integrate with GitHub. My problem is that although the integration appears to work, the only file in my Android application that has been saved to GitHub is MainActivity.java. I have tried to add files into GitHub but via the Website but this fails as there are too many files and it doesnt allow Folders to be added.
Has anyone else had this issue?
It's frustrating as when I make changes to MainActivity.java it gets saved and committed/pushed okay but the VCS in Android just doesn't see the other files I have changed such as the content_main.xml which I changed to see if it would then be added to GH.
I cannot seee how to add files within Android Studio to GH via VCS. Does anyone have any pointers where I may start? Thanks!
NB I have had a look through existing questions but none address my issue as far as I can tell.
Usually when you start a new project, Go on VCS -> Enable Version Controle Integration.
Then you should have the Version Control accessible on the Bottom Left of the IDE.
In the tab Local Changes, you will see Default and Unversioned Files.
Just take files from Unversioned Files to Default to start to track them.
To my shame once I checked Xiaomis suggestion I could see that my git was pointing to a directory lower than my /app directory. I tried to change in in my GitHub shell but was unable to do this as GitHub Desktop shell didn't recognise the new directory.
To fix my muddle I deleted my original repo and delted the .gitignore file and other git files from my Android project folder. I then opened Android Studio and went through the process of creating a new repo from there, circumventing GitHub entirely. This worked and enabled me to select my /app directory as the Git root.
Thanks go to Xiaomi who's suggestion made me notice that git was looking at the wrong root. Live and learn!

git eclipse pulls no project

I am new to working with repositories.
I'm forced to work with my team on academic project using git. My job is to write Android app.
The problem is when I wrote it, then pushed it to repo I want to pull it on different machine.
But when I pull it, I get only "source" files, no: (for example) R.java.
Moreover: I wanted to use "Clean project" Option, but it seems, that my Eclipse is not treating the pulled files as project (when I click "Clean..." I can choose any project in my workspace, but the download one is lacking).
Anyone could help me?
EDIT:
I've solved the problem:
Git doesn't push to repository automatic-generated files, like R.java. After you pull it back, you have to Clear project and rebuilt it. If it still doesn't work: try restarting Eclipse

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

android eclipse driving me mad?

I've quite new to Android development and specially Eclipse.
I'm busy on a project called, say 'HelloEclipse'. I've had some major changes ahead, in which I had to some very big changes.
So I made a zip file of c:\workspace\HelloEclipse, placed that in a save place. Went on to work on my project. Few hours later, I wanted to go back to the saved situation. Closed Ecplise, rebooted my computer, because I wanted to make sure there were no locked files. Deleted the old c:\workspace\HelloEclipse folder, place the version out of the ZIP file back.
This resulted in a totally corrupted workspace status. Could not go foward, nor backward. I've ended up, creating a new project, and pasted in everything, took me hours. I think this is quite stupid Eclipse behavior. I've also tried ot, export/import with a archive from out of Eclipse, also not succesfull.
So the two questions;
How am I suppose to save projects (without installing anything like subversion)?
Why is saving the files not enough, and why does that make Eclipse barf?
Thanks in advance!
Dennis
In eclipse if you want to reimport an old project from a ZIP, don't just copy the project files to the workspace, instead, extract the files to a normal dir outside the workspace.
Open Eclipse normally and select File>New Project>Android Project, just as you would to to create a new Android project, but then in the new android project window, you have a radio button giving you the choice to Create project from existing source, point it to the directory where you have extracted your old project and it should be re-imported to the WorkSpace alright.
Or do File>Import>Import existing project into workspace.
But in any case, don't put the files in the workspace manually to avoid conflicts, Eclipse will copy the files it needs itself upon importing.
There are hidden workspace files that you may have missed -- specifically, .classpath and .project. That said, it's a lot easier to make a backup copy (for example, of a released version so you can continue developing while supporting the release) by simply right-clicking on the top-level of the project in Eclipse and selecting Copy, then right-clicking and selecting Paste. The result will be a copy of the project after an opportunity to name the copy.
If you want to zip projects, you can do that by exporting them. If you want to delete existing projects, you should do that from inside Eclipse with a right-click. You can import the zip you previously exported.
If by save, you meant backing up the best something would be to create a local repository. If I were you, I would backup my code in an online repository too; to save it from hardware crashes or other disasters.
In your problem, you could have tried deleting the project alone and import the backup copy(from the zipped file) instead of deleting the entire workspace. Can't pinpoint the exact reason of why eclipse barfed but maybe because it messed up the workspace settings for eclipse. On a related note, I found this on the net.
Eclipse is rather troublesome at times but AFAIK it's the best IDE for android.
First of all, after several months of developing with eclipse I moved to IntelliJ (they have a community edition) and I found it much much better.
In intelliJ you can save local history, for example, you can set-up a label and go back to that label whenever you like without losing anything.
As for eclipse, you probably didn't zip some hidden files or something.
In addition, I remember having some similar problem, I had to resync the files with the project, try this one
Good Luck
I do the same thing with my projects. Instead of going through windows explorer to copy the files, I find copying the entire project from within Eclipse (right click the project in the explorer window pane, click copy, then click outside of the project and click paste) works just fine. When you paste it, you can specify a new save location and project name, which can be your backup space. Then you can switch between versions of the project no problem.

Copying an Android Project Folder is Not a FULL Backup?

Several weeks ago I took a snapshot of my Android project by simply copying the entire folder (Windows 7) to a network share.
A few weeks later, I wanted to build that snapshot in a new (and different) workspace. So I:
Created an empty folder for the
workspace,
Switched Eclipse to it,
Then used File > Import... to copy
that snapshot to the workspace.
I was then surprised to find errors in the project - errors that weren't there before I copied it over to the network share.
The first symptom was that only the last file in the project had multiple errors. I "fixed" that by entering into Eclipse (again!) Android's SDK location:
Windows > Preferences > Android > SDK Location: C:\android-sdk-windows
This resulted in numerous files now having errors, with the following hint at the console:
Android requires .class compatibility set to 5.0. Please fix project properties.
I fixed that by hovering over #override and selecting the Change workspace compliance and JRE to 1.5 balloon suggestion. This is strange because I checked Windows > Preferences > Java > Compiler > Compiler compliance level: and it was 1.6 before - Doesn't 1.6 include 1.5?
I was then left with only two errors stemming from #Overrides that shouldn't really be there (for methods implementing interface). So I removed them and now all is fine and the project builds and runs perfectly as before.
All nice and dandy but I was very surprised by the fact that I actually had to change anything in Eclipse, not to mention that I eventually ended up modifying the original source code (deleting #overrides only) to get it build - source code that had no complaints whatsoever weeks ago!
What could possibly explain this? Isn't copying an Android project folder a true full backup?
Being baffled by this discovery, I examined the workspace folder, using my beloved Emacs, and discovered that there is a hidden subdirectory named .metadata. This is probably where the secret lies.
My questions now are:
Does Eclipse store additional
information about the workspace
elsewhere?
What is a good approach to make
Android projects more independent,
as in "fully backup-able"?
Is there any use for the
.metadata/.log file? Can I safely
delete it?
I had those errors too when imported a project. If I'm remembering correctly, helped right-clicking in project name and selecting Android Tools -> Fix project properties...
After that errors disappeared.
“Android requires .class compatibility
set to 5.0. Please fix project
properties.” What’s this? It’s the
error I received after cloning a
repository and trying to import it
into Eclipse. There is reasonably
little information online about this,
couple discussions on mailing lists
but I figured I would write a post on
the solution to this.
After importing the project to your
workspace, you’ve received the error.
So what you need to do next is to
right click on the project -> Android
Tools -> Fix Project Properties. Now
this alone won’t fix the problem, you
need to restart Eclipse after this.
After that try building the project
again and it should work successfully
this time (unless you have bugs in the
code itself, I did).
I've found that Eclipse's metadata is stored, as you found, in the ./metadata folder of your workspace. I do not believe there are any additional folders but I will double check.
The best way to do a back up of the android project if you are using eclipse is to export it by right clicking the project, selecting export and exporting it as an archive, file system, etc. That way you can be sure you've backed it up in a way that Eclipse knows how to handle it.
Rather than delete it, why not make a copy of it first? Edit: I would also take a look at running eclipse.exe -clean in the command terminal. That may be more useful than manually deleting the .metadata folder.

Categories

Resources