Hello I am trying to implement a Glide configuration to set PREFER_ARGB_8888 however my Android project contains two build flavours (with two different package names)
i.e. com.myapp and com.myapp.development
Here is what I have tried
<meta-data android:name="${applicationId}.utils.GlideConfiguration" android:value="GlideModule"/>
<meta-data android:name=".utils.GlideConfiguration" android:value="GlideModule"/>
And here is my glide configuration class
public class GlideConfiguration implements GlideModule{
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
}
@Override
public void registerComponents(Context context, Glide glide) {
}
}
I do not have pro-guard enabled
This is the exception i get
java.lang.IllegalArgumentException: Unable to find GlideModule implementation
Local names (starting with .) only work in certain places, see table in documentation also the ${applicationId} will only work if your classes are in the same package as applicationId's name is. applicationId and package name are different species, most likely your flavor has a suffix .flavor1 which means that the GlideConfiguration class has to be in main.package.flavor1.util. You have two alternatives:
src/main/AndroidManifest.xml:
<meta-data android:name="package.name.for.main.code.GlideConfiguration" android:value="GlideModule" />
And create two files:
src/flavor1/java/package/name/for/main/code/GlideConfiguration.java
src/flavor2/java/package/name/for/main/code/GlideConfiguration.java
src/main/java/package/name/for/main/code/GlideConfiguration.java shouldn't exist
Create a src/<flavor>/AndroidManifest.xml for each flavor:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data android:name="package.name.for.flavor.GlideConfiguration" android:value="GlideModule" />
</application>
</manifest>
And create two files:
src/flavor1/java/package/name/for/flavor1/GlideConfiguration.java
src/flavor2/java/package/name/for/flavor2/GlideConfiguration.java
src/main/java/package/name/for/main/code/GlideConfiguration.java can co-exist but you have to register it in src/main/AndroidManifest.xml. This way you can have global config and per-flavor config (you can have as many GlideModules as you want).
Thank you
I've tried both alternatives but still having the same issue
Most helpful comment
Local names (starting with
.) only work in certain places, see table in documentation also the${applicationId}will only work if your classes are in the same package asapplicationId's name is.applicationIdand package name are different species, most likely your flavor has a suffix.flavor1which means that theGlideConfigurationclass has to be inmain.package.flavor1.util. You have two alternatives:Same package
src/main/AndroidManifest.xml:And create two files:
src/main/java/package/name/for/main/code/GlideConfiguration.javashouldn't existDifferent Packages
Create a
src/<flavor>/AndroidManifest.xmlfor each flavor:And create two files:
src/main/java/package/name/for/main/code/GlideConfiguration.javacan co-exist but you have to register it insrc/main/AndroidManifest.xml. This way you can have global config and per-flavor config (you can have as manyGlideModules as you want).