Closed jitrapon closed 5 years ago
Found this issue in Google Issue Tracker: https://issuetracker.google.com/issues/132323222
Thanks! The issue tracker is the right place to get v3 beta issues addressed.
The issue still exists.. Did you manage to figure it out?
@kndl22 Please comment on the public issue linked above
apparently the issue is that newer glide versions will generate a com.bumptech.glide.GeneratedAppGlideModuleImpl class with context inside constructor
and google maps 3 will try to instantiate without passing the constructor -> hence the reflection exception. not sure how to fix that from the outside though, it would help if we knew the actual glide version they're using
here the glide generated class glide:
com.github.bumptech.glide:glide:4.11.0 com.github.bumptech.glide:compiler:4.11.0
@SuppressWarnings("deprecation")
final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule {
private final AppGlideModule appGlideModule;
public GeneratedAppGlideModuleImpl(Context context) {
appGlideModule = new AppGlideModule();
if (Log.isLoggable("Glide", Log.DEBUG)) {
Log.d("Glide", "Discovered AppGlideModule from annotation: com.europapark.services.glide.AppGlideModule");
Log.d("Glide", "Discovered LibraryGlideModule from annotation: com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule");
Log.d("Glide", "Discovered LibraryGlideModule from annotation: net.kibotu.mediagallery.internal.progress.GlideConfiguration");
}
}
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
appGlideModule.applyOptions(context, builder);
}
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide,
@NonNull Registry registry) {
new OkHttpLibraryGlideModule().registerComponents(context, glide, registry);
new GlideConfiguration().registerComponents(context, glide, registry);
appGlideModule.registerComponents(context, glide, registry);
}
@Override
public boolean isManifestParsingEnabled() {
return appGlideModule.isManifestParsingEnabled();
}
@Override
@NonNull
public Set<Class<?>> getExcludedModuleClasses() {
return Collections.emptySet();
}
@Override
@NonNull
GeneratedRequestManagerFactory getRequestManagerFactory() {
return new GeneratedRequestManagerFactory();
}
}
and here the call within the gmaps 3 library
private static com.google.android.libraries.maps.c.zza zzb() {
com.google.android.libraries.maps.c.zza var0 = null;
try {
var0 = (com.google.android.libraries.maps.c.zza)Class.forName("com.bumptech.glide.GeneratedAppGlideModuleImpl").getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException var2) {
if (Log.isLoggable("Glide", 5)) {
Log.w("Glide", "Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored");
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException var3) {
throw new IllegalStateException("GeneratedAppGlideModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.", var3);
}
return var0;
}
The full stacktrace I am getting is the following one (3.1.0-beta):
java.lang.IllegalStateException: tname=DefaultPool2 - GeneratedAppGlideModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.
at com.google.android.libraries.maps.c.zzb.zzc(Glide.java:108)
at com.google.android.libraries.maps.c.zzb.zza(Glide.java:3)
at com.google.android.libraries.maps.c.zzb.zzb(Glide.java:240)
at com.google.android.libraries.maps.cq.zzh.zza(ResourceManagerImpl.java:7)
at com.google.android.libraries.maps.ij.zzaw.zza(Suppliers.java:7)
at com.google.android.libraries.maps.cq.zzi.run(Unknown Source)
at com.google.android.libraries.maps.fv.zzc.run(CancelableRunnable.java:7)
at com.google.android.libraries.maps.fv.zzae.run(Task.java:9)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.libraries.maps.fv.zzv.run(GmmThread.java:10)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.IllegalAccessException: java.lang.Class<com.bumptech.glide.GeneratedAppGlideModuleImpl> is not accessible from java.lang.Class<com.google.android.libraries.maps.c.zzb>
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at com.google.android.libraries.maps.c.zzb.zzc(Glide.java:101)
at com.google.android.libraries.maps.c.zzb.zza(Glide.java:3)
at com.google.android.libraries.maps.c.zzb.zzb(Glide.java:240)
at com.google.android.libraries.maps.cq.zzh.zza(ResourceManagerImpl.java:7)
at com.google.android.libraries.maps.ij.zzaw.zza(Suppliers.java:7)
at com.google.android.libraries.maps.cq.zzi.run(Unknown Source)
at com.google.android.libraries.maps.fv.zzc.run(CancelableRunnable.java:7)
at com.google.android.libraries.maps.fv.zzae.run(Task.java:9)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.libraries.maps.fv.zzv.run(GmmThread.java:10)
at java.lang.Thread.run(Thread.java:761)
As you can see the problem is that the constructor is not accesible from your class.
I have done some tests and you are able to updated the visibility of this constructor by calling setAccesible()
method.
It would fix the issue.
The result code should be something like:
@Nullable
private static com.google.android.libraries.maps.c.zza zzc(Context var0) {
com.google.android.libraries.maps.c.zza var1 = null;
try {
Constructor<?> constructor = Class.forName("com.bumptech.glide.GeneratedAppGlideModuleImpl").getDeclaredConstructor(Context.class);
constructor.setAccessible(true);
var1 = constructor.newInstance(var0.getApplicationContext());
} catch (ClassNotFoundException var3) {
if (Log.isLoggable("Glide", 5)) {
Log.w("Glide", "Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored");
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException var4) {
throw new IllegalStateException("GeneratedAppGlideModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.", var4);
}
return var1;
}
@JcMinarro Thanks for the follow up on this and for adding it to the public bug.
Hello!
Migrating to Maps SDK 3.0.0-beta with existing app that is already using Glide.
Glide version: 4.8.0
Currently, we are creating our own GlideModule implementation class that overrides the AppGlideModule and is annotated with
@GlideModule
.This seems to cause the app to crash when instantiating the SupportMapFragment.
Looking at the obfuscated code, here is the line that causes the error:
var0 = (com.google.android.libraries.maps.c.zza)Class.forName("com.bumptech.glide.GeneratedAppGlideModuleImpl").getDeclaredConstructor().newInstance();
It would then fail to instantiate. The generated class does exist in the build directory. The code seems to be executed on a separate background thread as when I put a breakpoint there, I was still able to move the map around (yes, the map successfully generates and shows marker and everything until that line).Any suggestions would greatly help us. We don't want to be removing our implementation of the Glide module.