I have two jars, the left.jar
and the right.jar
. They are similar but not identical.
left.jar:
package com.mydomain.config
public class PkgConfig {
public static int getID() {
throw new RuntimeException();
}
public static String getLeftValue() {
throw new RuntimeException();
}
// the rest of the methods are the same with right.jar
}
right.jar:
package com.mydomain.config
public class PkgConfig {
public static int getID() {
throw new RuntimeException();
}
public static String getRightValue() {
throw new RuntimeException();
}
// the rest of the methods are the same with left.jar
}
In my activity, I do this:
public void myMethod() {
if(com.mydomain.config.PkgConfig.getID() > 1000) {
mDeviceValue = com.mydomain.config.PkgConfig.getLeftValue();
}
else {
mDeviceValue = com.mydomain.config.PkgConfig.getRightValue();
}
}
And this is how I declared the dependency:
compileOnly files('libs/left.jar')
compileOnly files('libs/right.jar')
This setup gives me an error saying
error: cannot find symbol method getRightValue()
My goal is to create one APK out of this. I know I can use sourcesets and do this:
leftCompileOnly files('libs/left.jar')
rightCompileOnly files('libs/right.jar')
but it creates two APKs. Is there a way to go around this problem?