Issue 1:
Glide Version:3.8.0

Integration libraries: no

Device/Android Version: all version

Issue details / Repro steps / Use case background:

Image crops the wrong ratio when it first time was laoded. It was solved after I refresh the data and reloads the image. I found it may cause by the placeholde , if I change the placeholde to color resource or appropriate image size (such as 320x160 in 720 devices) then it woks fine. I want to use the unique placeholder image for every resolution, so I use centerCrop in ImageView. How to make it show the right ratio in first time ?

Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with(activity)
.load(new GlideUrl(url, mHeader))
.error(error)
.placeholder(placeHolder)
.into(target)

Layout XML:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="15dip"
android:paddingRight="15dip">

<LinearLayout
android:id="@+id/fragment_main_feed_header_theme1_ll"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:orientation="vertical">

<ImageView
android:id="@+id/fragment_main_feed_header_theme1_iv"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/picture_loading_placeholder_max"/>

<TextView
android:id="@+id/fragment_main_feed_header_theme1_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:gravity="center"
android:includeFontPadding="false"
android:singleLine="true"
android:textColor="@color/hei_333333"
android:textSize="12sp"/>
</LinearLayout>

<LinearLayout
android:id="@+id/fragment_main_feed_header_theme2_ll"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<ImageView
android:id="@+id/fragment_main_feed_header_theme2_iv"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/picture_loading_placeholder_max"/>

<TextView
android:id="@+id/fragment_main_feed_header_theme2_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:gravity="center"
android:includeFontPadding="false"
android:singleLine="true"
android:textColor="@color/hei_333333"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>

Stack trace / LogCat:

paste stack trace and/or log here

Issue 2:
Glide Version: 4.1.1

Issue details:

I create a new project named app, and then create a new module named mylibrary. I include glide4 dependency both in my app module and library module followed by doc

app/build.gradlecode:

apply plugin: 'com.android.application'

android {
...
}

dependencies {
compile project(":mylibrary")
compile 'com.github.bumptech.glide:glide:4.1.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
}

mylibrary/build.gradle code:

apply plugin: 'com.android.library'

android {
...
}

dependencies {
compile 'com.github.bumptech.glide:glide:4.1.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
}

Then I create classes extends AppGlideModule both in app module and library module in order to use GlideApp (Glide generated API) in these two modules.

package com.myapp.app;

@GlideModule
public class MyAppModule extends AppGlideModule {
}

package com.myapp.mylibrary;

@GlideModule
public final class MyLibraryModule extends AppGlideModule {
}

But after running the demo, crash occurs when I call GlideApp.with(this) in MainActivity belongs to app module.

crash logcat:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ClassCastException: com.myapp.mylibrary.GlideRequests cannot be cast to com.myapp.app.GlideRequests
at com.laoyouzhibo.a.GlideApp.with(GlideApp.java:87)

I found GeneratedAppGlideModuleImpl and GeneratedRequestManagerFactory are duplicated inside app module and library module. IDE reminds me duplicate class found in the file.

If I make MyLibraryModule extend LibraryGlideModule, I cannot find GlideApp in my library module.

@GlideModule
public final class MyLibraryModule extends LibraryGlideModule {
}

This is a simple demonstration for my situation. My application module and a couple of library modules depend on glide.