When you're developing an app in Android Studio and need to separate a third-party SDK library for production and sandboxing, I used Flovor to divide the build, and sandbox also uses the same code of product, so I used symbolic links to refer to the code.
app/build.gradle
android {
(abridgement)
Flavors {
product {}
sandbox {}
}
(abridgement)
}
app/src
% ln -s product sandbox
% ls
product
sandbox -> product
If you do like this, it will work normally on Android Studio, and the project tree will also be displayed properly with the flavor name.
So, after a while, It was a project written in Java, but when adding functions, I decided to write a new part in Kotlin.
Therefore, it is also necessary to refer to Java classes from Kotlin, When the flavor is specified as sandbox, the Java class of the Symbolic link destination may be referred to. It should have been referenced and complemented normally on Android Studio ...
error
Unresolved reference: packagehoge
Unresolved reference: classmoge
I get an error like this when building.
There is no problem if the code structure is Java only or Kotlin only. It seems to happen when I try to reference a Java class from Kotlin.
Let's set it properly without wearing sideways
app/build.gradle
android {
(abridgement)
Flavors {
product {}
sandbox {}
}
(abridgement)
sourceSets {
sandbox {
sandbox.manifest.srcFile 'src/product/AndroidManifest.xml'
sandbox.assets.srcDirs += 'src/product/assets'
sandbox.java.srcDirs += 'src/product/java'
sandbox.res.srcDirs += 'src/product/res'
}
}
(abridgement)
}
By making the above settings, the reference using Symbolic Link has disappeared, and the build can pass safely.