1

When I try opening the xml and gradle file in Android Studio,

Both of my files are missing the original content and is replaced by another content. Below are the screenshots:

XML File

xml file

Gradle File

Gradle File

Every day I open the files they behave like this. Currently I use my backup to replace the file contents but I need a solution to this problem. I don't know why this happens.

Can anyone please suggest me a solution? Or is there any other alternatives please suggest. I'm kinda stuck with this for days now.

This screenshot when i sync.

Gradle Sync enter image description here

Lano Angel
  • 299
  • 5
  • 18

2 Answers2

1

From what I am seeing this seems like the issue with the gradle and android studio setting version of yours.

Here is what you can do as first try! totally no Harm will happen following the steps

1: go to file menu and close project

2: close all instanses of android studio

3: then go to . C:\users\YOUR_USER_NAME\

4: you will see property files like . .gradle, .androidStudio3.3

deleting that old .gradle file will delete all the gradle cache deleting the .androidStudio3.3 file will delete the basic settings of android studio you did like the custom keymap,plugins,themes etc (optional)

5: so delete both those files mentioned above

6: after deleting those just fire up android studio, follow the steps and create a new project

step 6: creating a new project will make the android studio to download a fresh pack of gradle for your system, and new setting will be made.

6: when you are able to build the application then open your old project and see if the old error persists

Rizwan Atta
  • 3,222
  • 2
  • 19
  • 31
0

I have faced this issue many a times in IntelliJ.

  1. Disable offline mode in gradle settings.

  2. Use latest gradle distribution. Perhaps 4.6+

  3. Delete existing .gradle file. Since I work on Linux machine, it is in the Idea folder. Or in windows, you should find it in AppData.

  4. Refresh gradle.

Refresh gradle might take a while. If problem persists, then try installing gradle files from terminal and copy to .gradle file.

Sumukh Bhandarkar
  • 386
  • 1
  • 5
  • 14