Status Update
Comments
rk...@google.com <rk...@google.com>
tn...@google.com <tn...@google.com> #2
I believe you've been looking into this
at com.android.tools.idea.gradle.project.sync.idea.SdkSyncUtil.findMatchingSdkForAddon(SdkSyncUtil.kt:175)
at com.android.tools.idea.gradle.project.sync.idea.SdkSyncUtil.computeSdkReloadingAsNeeded(SdkSyncUtil.kt:127)
an...@steadfastinnovation.com <an...@steadfastinnovation.com> #3
hm, in fact let's discuss how we handle SDKs/addons etc. and also bootlclasspath
. We have an open issue with not supporting useLibrary
which we need to fix.
sg...@google.com <sg...@google.com> #4
The issue seems to be in
// Find the path to the android.jar, so we can match this to the sdks and find which one is in use.
val androidJarPath = bootClasspath.map { path ->
File(path)
}.firstOrNull { file ->
file.name == FN_FRAMEWORK_LIBRARY
} ?: return null
// There is no android.jar file in the bootClasspath, we can't find the SDK
// TODO: Maybe log here, this condition should never happen AFAIK.
return allAndroidSdks.first { sdk ->
sdk.rootProvider.getFiles(CLASSES).any { sdkFile ->
filesEqual(virtualToIoFile(sdkFile), androidJarPath)
}
}
i.e. it seems that android.jar
from the bootclasspath (as reported by AGP) is not found in any of Android SDKs registered with the IDE.
Al, do you modify bootclasspath for you project in some way? Also, can you please share a small project that reproduces the issue?
Bradley, you made some changes in this area in the past, does this ring a bell?
tn...@google.com <tn...@google.com> #5
Unfortunately I can't share that publicly, but would that trigger the issue? Is there some kind of filter on allAndroidSdks which only includes Google sourced SDKs? The reason I'm asking is we've seen issues trying to run apps from AS where our custom SDK is selected, and compiles the code without an issue, but AS pops up a "Please select an Android SDK" error.
tn...@google.com <tn...@google.com> #6
This is probably caused by allAndroidSdks
will be empty, and even though there is file with name android.jar
in bootclasspath, the code above will fail?
Description
java.nio
APIs can be used below API 26 withcoreLibraryDesugaring "com.android.tools:desugar_jdk_libs_nio:2.1.3"
. However, as described in thejava.nio
customizations documentationFor example, running the following on API 21 produces a
java.lang.UnsupportedOperationException
:This is expected per the documentation, but is not discoverable except at runtime.
However, when using
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.3"
(the non-nio artifact), usages of this API (and all otherjava.nio
APIs) produce lint errors unless wrapped in checks for API 26+.Is it possible to show lint errors just for the APIs that will fail at runtime when they're not wrapped in API checks for API 26+ when using
desugar_jdk_libs_nio
? That way the build will fail rather than discovering this at runtime.