Status Update
Comments
xa...@android.com <xa...@android.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)
[Deleted User] <[Deleted User]> #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.
je...@google.com <je...@google.com>
hu...@gmail.com <hu...@gmail.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?
cu...@gmail.com <cu...@gmail.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.
ch...@google.com <ch...@google.com>
jo...@google.com <jo...@google.com>
xa...@google.com <xa...@google.com>
hu...@google.com <hu...@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
Android gradle plugin version: 0.13.1
OS: MacOS
STEPS TO REPRODUCE:
1. Add a string to res/values/strings.xml
e.g. <string name="app_name">SimpleTest</string>
2. Add a product flavor which overrides this string:
productFlavors {
INT {
resValue "string", "app_name", "SimpleTest INT"
}
}
3. Execute:
gradle assembleINTDebug
EXPECTED RESULTS:
Build succeeds and the app is named "SimpleTest INT"
OBSERVED RESULTS:
Build fails with error:
:SimpleTest:mergeINTDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':SimpleTest:mergeINTDebugResources'.
> /Users/xyz/AndroidStudioProjects/SimpleTest/SimpleTest/build/generated/res/generated/INT/debug/values/generated.xml: Error: Duplicate resources: /Users/xyz/AndroidStudioProjects/SimpleTest/SimpleTest/build/generated/res/generated/INT/debug/values/generated.xml:string/app_name, /Users/xyz/AndroidStudioProjects/SimpleTest/SimpleTest/src/main/res/values/strings.xml:string/app_name
ADDITIONAL INFORMATION:
When I add a resource file via a sourceSet for this build flavor instead of using resValue, I can successfully override the app_name.
I think setting a resource with resValue should behave the same as when using a sourceSet.