简体   繁体   中英

Android Studio can't download and attach source codes for some library

in my case, it's like this source code like this

then, I click "download source" , but see this error: error

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:943)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$9.run(ExternalSystemUtil.java:972)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
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)

I'm sure my network is ok. And for many other libraries this is OK.SO,I'm confused of this.Can someone tell me why problem happened ? I also want to know how android studio download source code and attach them , is there any document for this?

For some unknown reason, the current ConstraintLayout dependency (see your build.gradle ) does not ship with source ! I am using a 'hack':

(A) Use your browser to save the official documentation to a file whose path depends on your SDK location. ( You will have to create any empty intermediate folders).

https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
file:///[your SDK]/docs/reference/androidx/constraintlayout/widget/ConstraintLayout.html

(B) From Android Studio Project view click External Files and navigate to your dependency. eg:

Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar

(C) Right click -> Library properties -> Specify documentation URL :

file:///[your SDK]/docs/reference

Not great, but better than nothing. I repeated it for MotionLayout and a few others.

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