1

I'm working on my first "gig" for Android. After importing this project from BitBucket, I'm noticing that.

A. it has a gradle wrapper.

B. The project's gradle file isn't syncing

C. the green dot on the folder icon is on a folder that's a level higher than the "app" folder.

D. There are no run configurations and I'm having a hard time making one.

How to do a change the root directory to the "app" folder? I'm hoping that gradle will sync up once I accomplish this.

I've heard it mentioned that I need to delete the iml files, but won't this mess up the upstream version if subsequent changes get merged? How can I fix this in my environment only?

Kind of new to git and Android, but am learning as I go in terms of working on projects other than my own. Thanks

-T

enter image description here

TJBlack31
  • 745
  • 4
  • 8
  • 23
  • The iml file ideally shouldn't be in VCS, so feel free to delete it to see if that fixes anything – OneCricketeer Jul 02 '18 at 06:13
  • The `settings.gradle` needs to be outside of app folder, then have a line `include :app`. You shouldn't move the project root into `app/` because that is the recommended structure Android Studio expects – OneCricketeer Jul 02 '18 at 06:15
  • @cricket_007 Thank you for the quick response. I removed the iml file, and the settings.gradle file looks good according to your recommendation. I now am getting an error that says "The project *** is not a Gradle-based project". Which is the same issue I had before. I researched it prior to my post, found [this] (https://stackoverflow.com/questions/39825831/android-studio-this-project-is-not-gradle-based-project) , which it's answer made me want to try changing the root directory in the first place. Back to square one. Any ideas? – TJBlack31 Jul 02 '18 at 06:34
  • In order to be a gradle based project, you need `build.gradle`, `settings.gradle`, and `app/build.gradle`. If you delete the IML file while the IDE is open, you need to close the project and reopen... Generally, I use the terminal to run `./gradlew build` before trying to open in the IDE – OneCricketeer Jul 02 '18 at 06:46
  • @cricket_007 Thank you. I noticed that in the directory, there are multiple iml files. Are there specific ones that I need to get rid of? There's even a folder version of a .iml – TJBlack31 Jul 02 '18 at 07:15
  • [All iml files should be ignored](https://www.gitignore.io/api/java,gradle,android,intellij,androidstudio), and can be removed – OneCricketeer Jul 02 '18 at 07:18
  • @cricket_007 So after deleting all of the visible iml files, I did an android studio invalidate cache/restart. and a folder icon appname.iml appeared with a green dot. After deleting that, the whole file tree vanished. Is the iml I deleted some kind of weird dependency in this case, do you think? – TJBlack31 Jul 02 '18 at 07:49
  • Again, don't delete the files while the IDE is open. If you do, you need to close the project from the File menu, then go back through the Open/Import dialog – OneCricketeer Jul 02 '18 at 08:17
  • @cricket_007 Copy that. Thank you again. when I import it, I choose "import from VCS" and supply the remote link. Maybe I should import it, delete the iml files, do a push to my remote, and then resupply the link for the updated repo? – TJBlack31 Jul 02 '18 at 09:13
  • You should add a `.gitignore` file I linked to, then copy this followed by a push https://stackoverflow.com/a/49969162/2308683 – OneCricketeer Jul 02 '18 at 09:15
  • @cricket_007 I went ahead and followed that procedure. I copied that gitignore file verbatim and it ended up deleting all of my gradle files. I still have no run configurations available and the root still hasn't changed – TJBlack31 Jul 02 '18 at 16:58
  • Hmm, it has `.gradle`, which is different than `*.gradle`. – OneCricketeer Jul 02 '18 at 18:13
  • @cricket_007 I went ahead and added a screen shot of the file structure under project mode. Maybe it might ring some bells. Does this look like it was made in intelliJ or something (still relatively new to this). Thanks for your help and persistence on this issue. – TJBlack31 Jul 02 '18 at 18:17
  • Should match https://developer.android.com/studio/projects/ ... Can you close the project, then rather than opening a folder, select only the `build.gradle`? – OneCricketeer Jul 02 '18 at 18:22
  • @cricket_007 Do you mean open the gradle file in the IDE? This is a dumb question, but how can I do that without the project open? – TJBlack31 Jul 02 '18 at 18:30
  • File > Open Project > Navigate to `build.gradle`. It will ask you to open the project as a Gradle Project on only open the file – OneCricketeer Jul 02 '18 at 21:24
  • @cricket_007 I tried this, but it uses some jar external libraries that it can't seem to connect with. It made the file tree look more traditional, but it didn't add any run configurations either. I was still unable to select a module. Is there a specific gradle that would do the trick? – TJBlack31 Jul 03 '18 at 16:28
  • The only "module" in a fresh project is `app`. Since I don't have your BitBucket repo, then I can't really say – OneCricketeer Jul 03 '18 at 16:30

0 Answers0