简体   繁体   中英

Android studio can't find ArrayList class

First of all I've been using Android studio for quite years but this has never happened before.

It seems like android studio's inner ArrayList class has vanished out of a sudden. I can't use ArrayList. It always says Can't find symbol ArrayList

I've cleaned rebuild and even invalidated caches and restarted several times but all in vain.

package dev.moutamid.testapp;


import java.util.ArrayList; //<--- this gives error


public class FragmentDashboard extends Fragment {


    private ArrayList<refUser> refUsersList = new ArrayList<>(); //<--- and this line
}

My android studio is up to date. I then opened a new project and tried to use ArrayList but it was still not showing. Feels like there's nothing related to ArrayList in studio.

Yesterday I got BSOD (Blue screen of death of Windows) and today it's happening. I'm using git repository to backup my project.

What could be the solution? I think Git has deleted ArrayList class because it already had corrupted several files before. I got luck due to the backups.

Well this is really weird. Would suggest you to try the following:

  1. Check the jdk in android studio and check the path. If you still facing this problem then install a fresh jdk which you download online and put in the new path and try.
  2. If this is also not working, back up all files and reinstall Android studio. Uninstall the current copy and install a fresh one.
  3. Well since you have had a Blue screen issue, would highly recommend to do a fresh install of windows. You haven't specified which Windows version you using so I am assuming you are using Windows 10. This link should help you out for Windows 10: https://support.microsoft.com/en-in/help/4000735/windows-10-reinstall
  4. And please keep taking a backup of whatever you need regularly.

I am guessing whether this is possible:

  1. On macOS, enter java -version in the console to check the currently installed Java version. For example, I output the following:

    ➜ ~ java -version java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

  2. Check whether the JDK location in the SDK Location in Project Struture in Android Studio is correct. For example, my address is as follows:

    /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

  3. Or select app in Modules and set the Source/Target Compatibility of Properties to try?

I hope it helps you~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM