22

I've searched this question and tried the proposed solutions with no success. I have a project which when I go to view the source file for lets say Fragment it takes me to the java class just fine.

Now when I go to File -> new project and go through all the same set up procedure. Now when I click the source for Fragment I am taken to the decompile class file.

My new project is SDK 28 and i've performed updates, but they don't change anything. By setting my compileSDKVersion to 27 and adjusting the dependencies accordingly, it works. But it should just work with SDK 28 and I don't understand what im missing

In the photo below you can see I have the sources for API28 installed

SDK Manager

Also when I click the Download Sources option below, I receive the following IDE error

Fragment Class

java.util.NoSuchElementException
at java.util.Collections$EmptyIterator.next(Collections.java:4189)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider.getSourceFile(GradleAttachSourcesProvider.java:160)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider.access$100(GradleAttachSourcesProvider.java:59)
at org.jetbrains.plugins.gradle.util.GradleAttachSourcesProvider$1$1.onSuccess(GradleAttachSourcesProvider.java:126)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$7.execute(ExternalSystemUtil.java:876)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$9.run(ExternalSystemUtil.java:905)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:713)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:165)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:315)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

My gradle file has the correct SDK set and you can see the .jar folders in the external libraries section of the project structure

external libraries

but when I click source all I see is Decompile Class!!

Kyle
  • 695
  • 6
  • 24
  • do you think this could be related to my issue? Please see here: https://stackoverflow.com/q/53374692/2597775 – sebasira Nov 21 '18 at 01:13
  • Sometimes it does show the source code even after downloading sources and refreshing. What worked for me was restarting Android Studio – Peter Chaula Sep 14 '19 at 18:29

2 Answers2

8

I'm gonna chalk this up to Google not yet releasing Android P source code, since when I change my SDK to 27, there is no problem and I have un/reinstalled SDK Platform 28 multiple times. I'll try again in a couple weeks and check if it has been released, until then I can continue my project with API 27.

Thanks!

Kyle
  • 695
  • 6
  • 24
6

1 click Tools > SDK Manager or click SDK Manager in the toolbar and select options like below fig. then click OK to download source codes. enter image description here

2 when download done,restart android studio!

Edit: Check build.gradle file:

android {
    compileSdkVersion 28 //here
    defaultConfig {
        applicationId "ht.dxs.testusingjava"
        minSdkVersion 15
        targetSdkVersion 28 //and here
        versionCode 1

Then in project view you will see:

enter image description here

navylover
  • 12,383
  • 5
  • 28
  • 41