Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glide 4.0.0-RC0: problems with recyclerview-integration #1972

Closed
ralph-bergmann opened this issue May 26, 2017 · 8 comments
Closed

Glide 4.0.0-RC0: problems with recyclerview-integration #1972

ralph-bergmann opened this issue May 26, 2017 · 8 comments

Comments

@ralph-bergmann
Copy link

ralph-bergmann commented May 26, 2017

Glide Version: 4.0.0-RC0
Integration libraries: okhttp3-integration, recyclerview-integration

Issue details / Repro steps / Use case background:

My app defines 6398 classes with 41887 methods and references 50126 methods. I don't use multidex.

When I add

implementation "com.github.bumptech.glide:recyclerview-integration:4.0.0-RC0"

to my build.gradle I get this error:

Information:Gradle tasks [:app:assembleDebug]
/Users/dasralph/development/androidstudio/nanodegree/PopularMovies/app/src/main/java/udacity/nanodegree/popularmovies/utils/DataBindingAdapters.java
Warning:(97, 57) [deprecation] BitmapDrawable(Bitmap) in BitmapDrawable has been deprecated
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v7/recyclerview/R$attr;
Error:com.android.dex.DexException: Multiple dex files define Landroid/support/v7/recyclerview/R$attr;
Error:	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:608)
Error:	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:563)
Error:	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:545)
Error:	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
Error:	at com.android.dx.merge.DexMerger.merge(DexMerger.java:194)
Error:	at com.android.builder.dexing.DexArchiveMergerCallable.mergeDexes(DexArchiveMergerCallable.java:66)
Error:	at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:54)
Error:	at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:37)
Error:	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error:	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error:	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error:	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error:	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/v7/recyclerview/R$attr;
Information:BUILD FAILED in 6s
Information:16 errors
Information:1 warning
Information:See complete output in console

To fix this I enable multidex. Now I have 6151 classes with 40977 methods and 49132 methods referenced.

Now the app compiles but when I run it I get this error:

Stack trace / LogCat:

FATAL EXCEPTION: main
Process: udacity.nanodegree.popularmovies.debug, PID: 18876
Theme: themes:{default=overlay:com.cyngn.hexo, iconPack:system, fontPkg:com.cyngn.hexo, com.android.systemui=overlay:com.cyngn.hexo, com.android.systemui.navbar=overlay:com.cyngn.hexo}
java.lang.RuntimeException: Unable to start activity ComponentInfo{udacity.nanodegree.popularmovies.debug/udacity.nanodegree.popularmovies.ui.MainActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.v7.widget.RecyclerView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2450)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5461)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.v7.widget.RecyclerView
    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
    at udacity.nanodegree.popularmovies.ui.MainActivity.onCreate(MainActivity.java:101)
    at android.app.Activity.performCreate(Activity.java:6251)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5461) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.v7.widget.RecyclerView
    at android.view.LayoutInflater.createView(LayoutInflater.java:645)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at udacity.nanodegree.popularmovies.ui.MainActivity.onCreate(MainActivity.java:101) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5461) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at android.view.LayoutInflater.createView(LayoutInflater.java:619)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at udacity.nanodegree.popularmovies.ui.MainActivity.onCreate(MainActivity.java:101) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5461) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: java.lang.IllegalStateException: Binary XML file line #16: Unable to find LayoutManager android.support.v7.widget.@2131296590
    at android.support.v7.widget.RecyclerView.createLayoutManager(RecyclerView.java:670)
    at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:599)
    at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551)
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at udacity.nanodegree.popularmovies.ui.MainActivity.onCreate(MainActivity.java:101) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5461) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.@2131296590" on path: DexPathList[[zip file "/data/app/udacity.nanodegree.popularmovies.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/udacity.nanodegree.popularmovies.debug-1/lib/arm, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    at android.support.v7.widget.RecyclerView.createLayoutManager(RecyclerView.java:651)
    at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:599) 
    at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551) 
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
    at udacity.nanodegree.popularmovies.ui.MainActivity.onCreate(MainActivity.java:101) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5461) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
	Suppressed: java.lang.ClassNotFoundException: Invalid name: android.support.v7.widget.@2131296590

I guess the important part is ClassNotFoundException: Invalid name: android.support.v7.widget.@2131296590 but I have no idea how to fix it :-(

@sjudd
Copy link
Collaborator

sjudd commented May 26, 2017

You don't want to enable multidex, but you do want to exclude the support library. A simple way to do that is to just exclude transitive dependencies when including the recycler view integration:

compile "com.github.bumptech.glide:recyclerview-integration:4.0.0-RC0" {
  transitive = false
}

@sjudd sjudd closed this as completed May 26, 2017
@sjudd sjudd added the question label May 26, 2017
sjudd added a commit to sjudd/glide that referenced this issue May 26, 2017
@ralph-bergmann
Copy link
Author

ralph-bergmann commented May 26, 2017

I still get this error:

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v7/recyclerview/R$id;

You can find the complete project here: https://github.com/the4thfloor/PopularMovies

Here's a minimal repro without using the latest alpha tools: https://groups.google.com/forum/#!msg/glidelibrary/NVhJdeVeH9U/r7B81_8PAgAJ

@TWiStErRob TWiStErRob reopened this May 27, 2017
@TWiStErRob
Copy link
Collaborator

@sjudd this is a packaging issue. The actual .jar file contains the R$*.class files. I don't think that's normal. See http://repo1.maven.org/maven2/com/github/bumptech/glide/recyclerview-integration/4.0.0-RC0/recyclerview-integration-4.0.0-RC0.jar
(also why we are around packaging, the javadoc jar is empty even for the main Glide module)

@the4thfloor use

implementation "com.github.bumptech.glide:recyclerview-integration:${libs.glide}@aar"

the .aar/classes.jar doesn't have those conflicting files.

@TWiStErRob TWiStErRob added this to the 4.0 milestone May 27, 2017
@ralph-bergmann
Copy link
Author

@TWiStErRob thanks a lot :-)

@sjudd
Copy link
Collaborator

sjudd commented Jun 16, 2017

Looking in to this now. The R class file only seems to appear in the recyclerview integration package, not the others. It's removed if I change the v7 recyclerview dependency to provided. That's probably ok, but I'm not sure I understand why it happens yet.

Still need to look into the javadoc issue.

sjudd added a commit to sjudd/glide that referenced this issue Jun 16, 2017
@sjudd sjudd closed this as completed in bfe1442 Jun 16, 2017
@TWiStErRob
Copy link
Collaborator

I think it is as simple as the other integration libs don't reference aar dependencies. Provided to me sounds better than manually excluding these classes; it better reflects the intention. Though you don't get implicit transitive dependencies then, which may be acceptable as most people must override with a latter version anyway.

@ralph-bergmann
Copy link
Author

The Android design support lib has the RecyclerView as dependency too but doesn't have this problem.
I think the solution is to create an empty public-res xml file. The design lib has an public-res file as well and this file doesn't contain any RecyclerView stuff.
Maybe this is the reason why the design lib doesn't make any problems.

@TWiStErRob
Copy link
Collaborator

@the4thfloor Design lib is an AAR and it depends on RecyclerView which is an AAR. recyclerview-integration is an AAR and it depends on RecyclerView which is an AAR. But there's a difference, because the recyclerview-integration is packaged as an AAR and a JAR, and only the JAR has this problem. I don't think public res would affect how JAR is packaged up.

Looking at this again since yesterday, I guess the JAR magic is causing the problem only so Sam made the right call of ignoring the specific files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants