1

I am using the Libgdx game library and I started having a problem when I upgraded from Android Studio 1.5 to 2.1 and upgraded the APIs and build tools that Android Studio prompted me to.

My project was working correctly prior to upgrading everything. Now when I run my program, I get a "file not found" error with a Libgdx function that should access a file. I stepped into the function to the point at which it calls file().exists() from java.io.File. When I jump to the declaration of file().exists(), Android Studio takes me the code

public boolean exists() {
    throw new RuntimeException("Stub!");
}

There is also a message at the top of the Window that says "Sources for Android API 19 Platform not found", with links that say "Download" and "Refresh (if already downloaded)" next to it. If I click "Download", Android Studio downloads some stuff, but the problem isn't fixed and the message doesn't go away. If I click "Refresh (if already downloaded"), nothing happens.

However, if I go to one of my source files, add import java.io.File and jump to the declaration of File.exists() from that file, Android Studio takes me to the code

public boolean exists() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkRead(path);
    }
    return ((fs.getBooleanAttributes(this) & FileSystem.BA_EXISTS) != 0);
}

Does anyone know what's going on here and how to fix it?

Ben Rubin
  • 6,909
  • 7
  • 35
  • 82

1 Answers1

1

Solution 01:

Just follow these steps: Settings --> Android SDK --> Launch Standalone SDK Manager --> download your needed SDK sources(in every Anroid Version's Sources for Android SDK) --> restart your Android Studio. If above don't help, make sure you have downloaded the required SDK sources, and reset the Android SDK Location to refresh.

Solution 02:

If above still don't helps, you can go to the C:\Users{USER_NAME}.AndroidStudio2.x\config\options\jdk.table.xml, and update the <root type="composite" /> in <sourcePath>. I updated my sources' path <root type="simple" url="file://D:/android/sdk/sources/android-24" /> in my API 24 Platform, and now it works.

Solution 03:

See this for help:https://stackoverflow.com/a/36825435/6482350

Community
  • 1
  • 1
DysaniazzZ
  • 825
  • 15
  • 29