ANDROID: After Rename .IML all Classes Red and Project won't Build - android

I was following a youtube tutorial on changing my android studio project name, so that when I download it from Google Play it doesn't display the old app name. The video suggested Refactor--> Renaming the .IML file, and then going to Modules.xml and changing the values there. Now my project won't build and all my classes have a red "J" on them and they're all grayed out. Please help!!!

You should have a structure like this:
root
.idea //remove it
mymodule
mymodule.iml //remove it
build.gradle
src
project.iml //remove it
build.gradle
settings.gradle
Follow these steps:
Remove the iml file in each module
Remove the .idea folder
Open the settings.gradle file and check if it is somenthing like:
include ':mymodule'
where mymodule is the name of the folder which contains the module (build.gradle and code)
resync and rebuild the project

Related

Put Android Studio application in sub-folder in Git

I have repository in Git that has this structure:
-web-app
-mobile-app
When I checkout the project in Android Studio my project has structure like this:
android-studio-project
-web-app
-mobile-app
The mobile-app folder is folder that contains the module of my android application end when I commit some changes some files and folders like gradle/wrapper, build.gradle, gradle.properties, settings.gradle are outside the folder mobile-app and my Git structure goes like this:
android-studio-project
-web-app
-mobile-app
-gradle/wrapper
-build.gradle
-gradle.properties
-settings.gradle
-...
I want to put all files and mobile-app folder in sub-folder in order to achieve first Git structure.
I tried to create a folder in Android Studio and move all needed files there but the project totally messed up.
I moved the gradle's files in to mobile-app folder but could not build the project at all.
Any ideas how can achieve the desired Git structure?

Missing setting.jar when importing a project to Android Studio

It was telling me that the module is not backed by Gradle and that it lacks a setting.jar file
I created other project and copy and pasted the setting.gradle file to the folder and then it

Remove extra folder from Android Project View in Android Studio

I have the library and 2 samples for it. Say my-sdk, sample1, sample2. The file structure is:
Project folder, inside it settings.gradle, my-sdk and samples folder. Inside samples I have sample1 and sample2 folders.
My settings.gradle:
include ':my-sdk', 'samples:sample1', 'samples:sample2'
The problem is:
In Android Project View I see 4 projects:
sample1
sample2
my-sdk
samples (empty)
How to remove samples folder from Android Project View?
BTW. I have file samples.iml inside samples folder. So looks like for me that Android Studio thinks thats samples is a module but it just a folder for other modules.
UPD If I try to remove this empty module from Module Settings F4 than IDE crashes.
Do these steps:
remove from the sample folder the .iml file
remove from the sample folder the build.gradle (if it exists)
run a ./gradlew clean and resync gradle project.
If it is not enough remove:
.idea : in this folder Android Studio saves the settings
.iml in each module. In these files Android Studio stores the module information
Delete these resources, and then reimport again the folder.

How to regenerate build.gradle file after deleting

I got an error with my Android project: Gradle project sync failed error, and then I searched the solution here. However, I deleted wrong file(build.gradle instead of .gradle in the user home directory). So how do I generate build.gradle file in Android Studio again?
Open your IDE and just create a file called build.gradlein the root folder if you deleted the top-level file, or inside a module if you deleted it.
It is a text file where you have to write your script.
You can copy the standard configuration, just copying from a new project. Of course you have to customize your file with your dependencies and your configuration.

gitignoring Android Studio app

In the file structure, you have
Project Name
.idea
app
build
libs
src
app.iml
build.gradle
build
gradle
...
I have .gitignored the build in the Project Name directory, but is it safe and should I also .gitignore build in the app directory?
Yes, it is safe. Files in build folder can be regenerated when you re-import the project next time.

Categories

Resources