Cloning down existing Android Studio project - android

I have been working on a local machine and pushing my changes up to Stash (Pretty much BitBucket).
Everything has been going fine but not I am trying to clone the code down to a co-workers machine and am having some serious issues with Android Studio.
I am importing the project through vcs, choosing git option, and providing the URL.
Whenever we try to get the project running we run into build problems and Gradle not working properly. The project is not initially shown as an Android project and we have to configure the framework. Then we have gradle saying it cannot find 'com.android.application' file. I have ensured that I have the correct Gradle version to work.
I think that I may not be pushing up the correct files to Stash, so when we clone the project it does not have enough information to build properly.
The files that I have not pushed up are the following:
build.gradle (at highest level not app level)
gradle.properties
gradlew
gradlew.bat
NAMEOFAPP.iml
.idea/.name
.idea/encodings.xml
.idea/gradle.xml
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml
.idea/copyright/profiles_settings.xml
.idea/dictionaries/USERNAME.xml
.idea/scope/scope_settings.xml
app/app.iml
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties

You definitely want to push up build.gradle. That is the file that describes the Gradle build for the project.
You will also want the .iml files pushed up, and the gradlew files (which are gradle scripts for different platforms), and probably the gradle/wrapper files.
You do not have to push up the .idea files. They specify the AS/IntelliJ workspace settings. It can be convenient to share these between collaborators as you will all be in the same environment, but it can also be frustrating having other people overwrite your preferred settings, so this is up to the developers in question.

Related

How to build an Android Studio project cloned from git?

I'm building a library for Android in Android Studio. In order to test and debug this library, I created a project with two modules: a library module (my code) and an app module (for testing)
Creating these was pretty easy. I just clicked File > New... > Project and followed the prompts. Afterwards I was able to write code, hit build, and observe the results in the app that was generated.
After a couple of months, everything was ready to deploy. I've been regularly committing my code and pushing it to a central repository, so another developer at my company cloned the repository and tried to open it in Android Studio. He was met with an entirely different view.
This is what I see:
This is what is seen if you clone the repo and open it:
When looking at the second view there's no way to build the project, there are no build configurations, no variants, and none of the gradle scripts seem to run.
If instead of cloning I just cp -r my entire project directory and open that in Android Studio, it opens perfectly. So the issue seems to lie with something in my .gitignore hiding an important configuration file necessary to build the project.
The .gitignore was generated for my automatically by Android Studio. It looks like this:
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
Everything there should be files generated by the build tools or local workspace configuration files, not project-level files necessary to compile. But I'm not very familiar with Android, its build steps, or the 800,000 things Android Studio is implicitly and secretly doing behind my back. Just opening the project in Android Studio causes 12 or so files to get modified on disk, so I know that it's doing a lot of things behind my back.
I can share any details about my configuration or project setup as necessary. I've spent a few hours on this already and can't figure out for the life of me how to get this project to build.
While it's probably not the proper solution (after all, Android Studio created the .gitignore for me), I found that removing /.idea/modules.xml from the .gitignore and checking in this file fixed all of my issues. Suddenly when I launched Android Studio it detected everything, some Gradle scripts ran, and I was able to build my project.

How to import an Android Studio project from android.googlesource.com?

I'm trying to open the DeskClockApp (https://android.googlesource.com/platform/packages/apps/DeskClock/) in my version of Android Studio. However, since no gradle files are downloaded, Android Studio is struggling to see the project as an Android-Gradle app.
I've tried downloading the source code as a zip, importing it as Git from Android Studio's VCS, etc. The online repository doesn't have the gradle files b/c the developer added a gitignore for gradle (makes sense). I also considered adding the gradle files myself but the project structure seems to be slightly different than the structure defined online. When I first import that project it says Android Framework detected, however, on configuring it for Android it cannot find any module to run, or even display the correct files (in the Project view). Is there any way to generate the correct gradle files for this? Maybe run it without gradle?

What is the role of .gradle .idea gradle folders in an Android project?

I could not find any resource explaining the need/purpose of .gradle .idea gradle folders in an android project. Can anyone explain in layman terms.
Explaining the .idea folder is simple: Android Studio is the development IDE - internally it bases on the same IDE framework as IntelliJ and IntelliJ uses the .idea folder to store all IDE related projects settings. For example which files are open, how the different UI elements has been configured, the run configurations,...
The .gradle directory on the other side stores for each used gradle version temporary files. Usually it contains cached files and lock files that make sure that two gradle instances runing at the same time don't conflict with each-other.
This means that usually you can delete such files without consequences - gradle will rebuild them if needed.

Android Studio 1.4.1 - Impossible to exclude .iml files in Subversion

it's frustrating, i uploaded my project to subversion and everything is perfect.
but I can not ignore the *.iml files and local.properties
the folders are ignored correctly, but the files are not ignored.
You should use an svn client to set the svn-property "svn:ignore" to your wished setting. svn supports wildcards like "*.iml". It is easiest in tortoisesvn but also possible via commandline:
svn propedit <Your Directory>

Android Logcat files on Hudson/Jenkins

we are using Hudson for CI of an Android project with Android emulator plugin to run UI tests on the emulator. A git project delivers the source code.
Now I see that in the git repo, for each build a logcat file is created and put in the git project folder, which is then pushed back to git. As we are expecting a lot of builds, this could easily spam the project folder. Does anyone know if it is possible to set the destination folder for the emulator logs?
I cannot find any options in the emulator plugin or Hudson anywhere.
The logcat files are named logcat_[some_number].log.
Best regards,
Kim
Upgrade to version 2.0 of the plugin (or newer) and you'll see these logcat files are now written to a temporary directory, rather than your workspace.
If you're using Hudson, possibly you only see the very old version 1.6 in the Update Centre.
Which is just another reason to upgrade to Jenkins! :)
However, if you can't upgrade either the plugin or Jenkins (for some weird reason), just use an "Execute shell" step to delete any logcat_*.log files at the start of each build.
These files are purely temporary anyway and should probably only exist in your workspace after a failed build — otherwise the logcat output is archived automatically as logcat.txt.
Add an ant task to rename the logcat file to your convenience and remove the oldest ones.
add the logs to the .gitignore file, if you want to exclude them from your repository.

Categories

Resources