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.
Related
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?
I've been using Android Studio on Windows 8 with this project for a couple months, and earlier today the sidebar suddenly doesn't show any of the project files (just the Gradle Scripts). At the same time, the Gradle build also keeps failing, with dozens of errors of the form "cannot find symbol class X". Finally, when I go into the "Build" menu, it only has a "make project" option but not a "make module 'app'" option, and I suspect that it is unaware of the module 'app' anymore.
This error persists when I switch to different Git branches of the same project, but not when I switch to a different project. I've tried re-importing the project (including deleting the .iml files and .idea folder beforehand), I've tried clearing out the folder and re-syncing, and I've tried reinstalling Android Studio.
I've included a screenshot below that shows some of the Gradle errors and the sidebar that doesn't contain any of the project files.
Try cleaning project by selecting clean project option under Build menu.
Also try building after deleting builds dir in the project.
I'd like to know what is that trash that was pushed by Android Studio to bitbucket. Those files and directories don't even exist in a project directory. What are they and how can I get rid of them. BitBucketScreenshot
.gitignore? If so, why again project directory doesn't contain any of these?
Greetings.
Problem is solved. By accident I have setup IDE settings remote repo the same as project one.
I'm using Android Studio version 1.5.1 and we have a problem when cloning and working with Github.
In my gitignore file I got a text saying *.iml, as I understand this means that all my iml files are ignored by git and not uploaded. When my project collaborators are cloning my project, they get a error message telling them that there is 2 missing iml files. They are asked to either keep or remove them. It doesn't matter which they do beacuse it still gives the same problem. They cannot code or build anything.
As I understand the iml files should not be uploaded to github but instead Android Studio should automaticly generate them when it is building or importing a project.
What have we done wrong?
After cloning the repo, you should re-open the project with
File -> Open
and select your project you've just clone and android studio will re-build, re-index and re-create the .iml file :)
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.