0

I have recently upgraded my android studio to Arctic fox latest version. But the app didn't run showing runtime errors. I searched through the internet and changed the compileSdkVersion and targetSdkVersion to 31 and the app run correctly and haven't shown errors for some days.

After some days, all of a sudden, Android studio started showing some weird errors and totally different codes in both java classes and xml files. So, I opened the projet directory and opened the java file and xml in notepad and found that the code there is correct but only showing different codes in the Android studio editor.

My problems are listed below

Some java classes don't show the actual code and instead shows like this below

<component name="libraryTable">
  <library name="Gradle: androidx.test:monitor:1.4.0@aar">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/../../Gradle/caches/transforms-3/ca7a7de16b2505fe395c4817e5fa80ba/transformed/monitor-1.4.0/jars/classes.jar!/" />
      <root url="file://$PROJECT_DIR$/../../Gradle/caches/transforms-3/ca7a7de16b2505fe395c4817e5fa80ba/transformed/monitor-1.4.0/res" />
      <root url="file://$PROJECT_DIR$/../../Gradle/caches/transforms-3/ca7a7de16b2505fe395c4817e5fa80ba/transformed/monitor-1.4.0/AndroidManifest.xml" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$PROJECT_DIR$/../../Gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.4.0/2770e38fa6d39242c2fa2e9d2ca3275b1d9debd8/monitor-1.4.0-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$PROJECT_DIR$/../../Gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.4.0/5d892d39aae695079e3ecc7a841336ff3aeaf40/monitor-1.4.0-sources.jar!/" />
    </SOURCES>
  </library>
</component>

with a series of NULL after the </component> tag.

Some of the xml files shows weird codes like below. ( Below is an activity layout file ).

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Sep 20 14:31:49 IST 2021
sdk.dir=C\:\\Users\\Admin\\AppData\\Local\\Android\\Sdk
<iye=
</menu>=
<menu=xmlns\:android\="http\://schemas.android.com/apk/res/android">
<?xml=version\="1.0" encoding\="utf-8"?>

And some xml files show the menu layout code in the activity layout file like below.

// This is an activity layout file but the activity runs with expected layout when app runs.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/delete"
        android:title="Delete"
        android:icon=""
        app:showAsAction="always|collapseActionView">
    </item>
</menu>

And even some layout files show the uncompleted Java code of some classes.

In the Android manifest file, the directory of the activity classes and services inside the android:name="" shows the error as,

Class referenced in the manifest, com.example.project.main.MainActivity, was not found in the project or the libraries

Unresolved class 'MainActivity'

In the Build window, I get a warning as

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

The app runs smoothly as expected though.

What I have done so far

  1. Tried Doing Invalidate caches and restart
  2. Cleaned the project and rebuilded it
  3. Restarted the system and Android studio.
  4. Deleted /.gradle and /.idea folder
  5. Degraded compileSdkVersion and targetSdkVersion to 30 and tried
  6. Tried Sync project with Gradle files
  7. Tried to download the sources for Android 31 but sources not found in SDK Manager.
  8. Checked the Android manifest package name and applicationId in build.gradle to be correct.

None of the above methods helped me to solve the problem.

user13608097
  • 66
  • 2
  • 9

0 Answers0