Fixed
Status Update
Comments
[Deleted User] <[Deleted User]> #2
We could add an API to make the weighted distance customizable, aosp/3271691 has more info.
de...@gmail.com <de...@gmail.com> #3
I think gradle-tool to 3.1.0-beta1 or 3.2.0-alpha01 might generate same problem.
Which means:
3.1.0-betaX or 3.2.0-alpha0X
Which means:
3.1.0-betaX or 3.2.0-alpha0X
uc...@google.com <uc...@google.com> #4
Not reproduced, tested in 3.1 Beta-4, please share a sample project or share app & root gradle configuration files.
qi...@gmail.com <qi...@gmail.com> #5
I have a similar issue with 3.1 rc2, I have 3 dimensions for my product flavors:
- brand (e.g. foo, bar)
- api (e.g. min21, pre21)
- target (e.g. internal, external)
In sourcesSets I use for example fooMin21InternalDebug to override some resource files.
When assmebling build via UI (Android Studio Run button), I got error saying it can't find fooMin21InternalDebug. If I run a ./gradlew :app:sourceSets, I can see it's there.
But if I run assemble with command line, I don't have this problem.
- brand (e.g. foo, bar)
- api (e.g. min21, pre21)
- target (e.g. internal, external)
In sourcesSets I use for example fooMin21InternalDebug to override some resource files.
When assmebling build via UI (Android Studio Run button), I got error saying it can't find fooMin21InternalDebug. If I run a ./gradlew :app:sourceSets, I can see it's there.
But if I run assemble with command line, I don't have this problem.
uc...@google.com <uc...@google.com> #6
please share a sample project to reproduce this issue.
de...@gmail.com <de...@gmail.com> #8
Workaround works
zb...@gmail.com <zb...@gmail.com> #9
Thanks #7! Can confirm workaround works.
em...@gmail.com <em...@gmail.com> #11
The workaround does not work for me. My use case is different.
```
sourceSets {
// This lets us write test utility code that can be used by both unit tests and android tests
commonTest {
java
}
test {
java.srcDirs += commonTest.java.srcDirs
}
androidTest {
java.srcDirs += commonTest.java.srcDirs
}
}
```
This has worked for years, but fails now with AGP 3.1.0. Stack Overflow post:https://stackoverflow.com/questions/49601232/the-sourceset-commontest-is-not-recognized-by-the-android-gradle-plugin-perha
Error is
> The SourceSet 'commonTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
```
sourceSets {
// This lets us write test utility code that can be used by both unit tests and android tests
commonTest {
java
}
test {
java.srcDirs += commonTest.java.srcDirs
}
androidTest {
java.srcDirs += commonTest.java.srcDirs
}
}
```
This has worked for years, but fails now with AGP 3.1.0. Stack Overflow post:
Error is
> The SourceSet 'commonTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
uc...@google.com <uc...@google.com> #12
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
je...@google.com <je...@google.com>
xa...@google.com <xa...@google.com> #13
We changed how 3.1 behaves with source sets because we've seen many people use the wrong name for the source sets and never realize what the problem was. Our plugin would just silently ignore the misspelled ones.
You should make sure of the name of the source set you are using by running ./gradlew <module>:sourceSets to see a full list of all the source sets.
I've done some tests with 3.2.0-alpha8, and cannot reproduce all issues. I'd like to see some gradle file to see exactly what is being done.
#1: I'm guessing you have a flavor called "mock" ?
I created an app with flavors like you seem to have and I cannot reproduce.
Here's what I added to a basic build.gradle file:
android {
flavorDimensions 'foo'
productFlavors {
mock {}
prod {}
}
sourceSets {
prodDebug.java.srcDirs += "src/xyz/java"
mockDebug.java.srcDirs += "src/abd/java"
}
}
#5 I cannot reproduce either. Here's how I changed a basic project:
android {
flavorDimensions 'brand', 'api', 'target'
productFlavors {
foo {
dimension 'brand'
}
bar {
dimension 'brand'
}
min21 {
dimension 'api'
}
pre21 {
dimension 'api'
}
internal {
dimension 'target'
}
external {
dimension 'target'
}
}
sourceSets {
fooMin21InternalDebug {
java.srcDirs += '/src/sdf/java'
}
}
}
#11 This is expected as not supported anymore. Adarsh, we should document this better.
Note that you don't need to create a source set for that. You can do directly:
test {
java.srcDirs += 'src/commonTest/java'
}
androidTest {
java.srcDirs += 'src/commonTest/java'
}
You should make sure of the name of the source set you are using by running ./gradlew <module>:sourceSets to see a full list of all the source sets.
I've done some tests with 3.2.0-alpha8, and cannot reproduce all issues. I'd like to see some gradle file to see exactly what is being done.
#1: I'm guessing you have a flavor called "mock" ?
I created an app with flavors like you seem to have and I cannot reproduce.
Here's what I added to a basic build.gradle file:
android {
flavorDimensions 'foo'
productFlavors {
mock {}
prod {}
}
sourceSets {
prodDebug.java.srcDirs += "src/xyz/java"
mockDebug.java.srcDirs += "src/abd/java"
}
}
#5 I cannot reproduce either. Here's how I changed a basic project:
android {
flavorDimensions 'brand', 'api', 'target'
productFlavors {
foo {
dimension 'brand'
}
bar {
dimension 'brand'
}
min21 {
dimension 'api'
}
pre21 {
dimension 'api'
}
internal {
dimension 'target'
}
external {
dimension 'target'
}
}
sourceSets {
fooMin21InternalDebug {
java.srcDirs += '/src/sdf/java'
}
}
}
#11 This is expected as not supported anymore. Adarsh, we should document this better.
Note that you don't need to create a source set for that. You can do directly:
test {
java.srcDirs += 'src/commonTest/java'
}
androidTest {
java.srcDirs += 'src/commonTest/java'
}
zb...@gmail.com <zb...@gmail.com> #14
Thanks, Xav. The OP is when running the app in a certain variant in Android Studio, not on the gradlew CLI. Have you tried running from Android Studio Run button? If not, try using Android Studio 3.1.0 RC3 with the projects and see what we mean.
xa...@google.com <xa...@google.com> #15
ah I will check, that's good info. thanks.
qi...@gmail.com <qi...@gmail.com> #16
+1 #14
exactly, IMHO it's mostly a bug in Android Studio UI. Everything works fine with command line :)
exactly, IMHO it's mostly a bug in Android Studio UI. Everything works fine with command line :)
xa...@google.com <xa...@google.com> #17
Ok i can repro with Instant Run enabled. I will investigate.
Description
in app/build.gradle:
sourceSets {
main.java.srcDirs += "blabla bla"
test.java.srcDirs += "blabla bla"
androidTest.java.srcDirs += "blabla bla"
prodDebug.java.srcDirs += "blabla bla"
mockDebug.java.srcDirs += "blabla bla"
prod.java.srcDirs += "blabla bla"
testProd.java.srcDirs += "blabla bla"
androidTestProd.java.srcDirs += "blabla bla"
mock.java.srcDirs += "blabla bla"
testMock.java.srcDirs += "blabla bla"
androidTestMock.java.srcDirs += "blabla bla"
}
click "run" in Android Studio :
something goes wrong:
Error:org.gradle.api.GradleException: The SourceSet 'mockDebug' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
However, I can do "./gradlew clean build" or "./gradlew assembleProd installProdDebug" etc.
But, if I do it in command-line, the app cannot be built completely, it can install the app on the target device, but the app will crash like "xxxx.dex" problem.
Can anyone help me?