All Activities and layouts got corrupted in Android Studio-ThrowExceptions

Exception or error:

I am working on a projects since 3 months. Today most of my activities and xml files got corrupted. I have tried deleting workspace.iml file but it remains same.Local History in VCS is also empty. Is there any way to recover my code or solve this issue.
Note These files are same as previous if I open then in Notepad app/scrc/main/, but showing different in Android studio

Here what my code looks like now

<component name="libraryTable">  <library name="Gradle:">
  <root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/firebase-measurement-connector-impl-17.0.3.aar/fb2536827bf92d82ab72080a9863eb78/res" />
  <root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/firebase-measurement-connector-impl-17.0.3.aar/fb2536827bf92d82ab72080a9863eb78/jars/classes.jar!/" />

gradle file:

apply plugin: ''apply plugin: ''android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.apkfeast.class11walkthrogh"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner ""
    multiDexEnabled true
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), ''        }  }}dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation ''
implementation ''
testImplementation 'junit:junit:4.12'
androidTestImplementation ''
androidTestImplementation ''
implementation ''
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation ''
implementation ''
implementation ''
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.firebaseui:firebase-ui-database:4.2.1'
implementation 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.github.bumptech.glide:annotations:4.8.0'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation ''
implementation ''
implementation ''
implementation ''
implementation ''}apply plugin: ''


<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android=""
android:screenOrientation="portrait" >

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <activity android:name=".Splash">
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.LAUNCHER" />

    <activity android:name=".Hyderabad" />
    <activity android:name=".Mirpurkhas" />
    <activity android:name=".SelectBoard" />
    <activity android:name=".Quiz" />
    <activity android:name=".Notes" />
    <activity android:name=".fedral" />
    <activity android:name=".sukkur" />
    <activity android:name=".larkana" />
    <activity android:name=".aghakhan" />
    <activity android:name=".sarghoda" />
    <activity android:name=".Rawalpindi" />
    <activity android:name=".Faisalabad" />
    <activity android:name=".Multan" />
    <activity android:name=".Gujranwala" />
    <activity android:name=".lahore" />
    <activity android:name=".karachi" />
    <activity android:name=".sahiwal" />
    <activity android:name=".dgkhan" />
    <activity android:name=".peshawar" />
    <activity android:name=".bahawalpur" />
    <activity android:name=".balochistan" />
    <activity android:name=".hydchem" />
    <activity android:name=".hydphy" />
    <activity android:name=".hydbio" />
    <activity android:name=".hydeng" />
    <activity android:name=".hydisl" />
    <activity android:name=".hydurd" />
    <activity android:name=".hydmat" />
    <activity android:name=".hydpak" />
    <activity android:name=".hydviewdown" />
    <activity android:name=".mpkVD" />
    <activity android:name=".fedVD" />
    <activity android:name=".sukVD" />
    <activity android:name=".larVD" />
    <activity android:name=".sarVD" />
    <activity android:name=".rawVD" />
    <activity android:name=".faiVD" />
    <activity android:name=".mulVD" />
    <activity android:name=".gujVD" />
    <activity android:name=".lahVD" />
    <activity android:name=".khiVD" />
    <activity android:name=".sahVD" />
    <activity android:name=".dgkVD" />
    <activity android:name=".pesVD" />
    <activity android:name=".bahVD" />
    <activity android:name=".balVD" />
    <activity android:name=".result" />
    <activity android:name=".bioquiz" />
    <activity android:name=".chemquiz" />
    <activity android:name=".phyquiz" />
    <activity android:name=".full" />



I have fixed it by deleting all the files in C:\Users\cc.AndroidStudio3.2\system\caches.

How to solve:

I also had the same problem this morning.
I thought this was due to migrating to AndroidX but
It was wrong. It may occur due to improper indexing and building for e.g. the indexing is force stopped. or due to some IDE issues.

The isuue resolved by deleting gradle and .idea folder in project
and clearing cache of Android Studio IDE by D:\Users\ABCD.AndroidStudio3.2\system\caches.
And issue was resolved.

Note:- Please take Project Backups Daily.


Erasing the cache of the Android studio will resolve the problem, for that you have to go to:


(On windows)

and on Mac:


Delete all the files there and restart the Android studio.


I solved that by

Close project you are working on

//This enables deleting all cache files
Close android studio

navigate to .AndroidStudio folder and then sytem then cache

delete the cache

Go to your project folder delete delete gradle and .idea folder

delete app.iml file too

import project dont open as exixting.

Boom you done.


Close android studio then delete the cache found in


Important not to modify a file before having deleted the android studio cache

If you modify a file you risk not being able to recover your old code

Leave a Reply

Your email address will not be published. Required fields are marked *