Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Api 24 can't find sources

I have this grade file:

//ext.support_library_version = '24.0.0'

    android {
        compileSdkVersion 24
        buildToolsVersion '24.0.0'

        defaultConfig {
            applicationId "---"
            minSdkVersion 21
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }
    ...
    }

But then when i try to open any android related class, it says i haven't got sources for api24, even tho the buildToolsVersion '24.0.0' is installed. Any idea why?

like image 551
johnny_crq Avatar asked Jun 16 '16 11:06

johnny_crq


Video Answer


2 Answers

Sources for Android N are not yet published and not available for installation in the SDK manager. When the source package becomes available, you need to install it separately, as with any previous SDK version.


Update 2016-08-24: The Android API 24 sources are now available in the SDK manager.

After downloading you might need this trick to refresh the SDK installation.

like image 135
laalto Avatar answered Oct 18 '22 18:10

laalto


I had the same problem with API 25 and Android Studio 2.2

Try the following:

  1. Close Android Studio.

  2. Open ~/Library/Preferences/AndroidStudio2.2/options/jdk.table.xml or C:\Users{USER_NAME}.AndroidStudio2.2\config\options\jdk.table.xml

Note the Android Studio version in the pach.

  1. Locate <sourcePath> for Android API 24 Platform and for previous one. You can look that <sourcePath> for problem API hasn't second <root> element with url.

  2. Investigate path of sources, check that sources was really installed.

  3. Copy <root> from another <sourcePath> and set correct url. It will be similar to

    <sourcePath>
      <root type="composite">
        <root type="simple" url="file://$USER_HOME$/Library/Android/sdk/sources/android-24" />
      </root>
    </sourcePath>
    
  4. Save the file and start Android Studio

https://stackoverflow.com/a/36825435/1263771

like image 1
tse Avatar answered Oct 18 '22 19:10

tse