MaterialPreferenceLibrary icon indicating copy to clipboard operation
MaterialPreferenceLibrary copied to clipboard

Breaks ConstraintLayout preview rendering in Android Studio

Open jasongisstl opened this issue 9 years ago • 6 comments

If I add a dependency on this library to a project in Android Studio, it will prevent Android Studio's preview rendering of layouts using ConstraintLayout from working.

They do still seem to work fine at runtime, however.

Tested using Android Studio 2.3 Beta 1.

This can be seen with a brand new project.

  • Create a layout using ConstraintLayout.
  • Add maven { url 'https://jitpack.io' } to the Project's build.gradle file's repositories section.
  • Add compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:9' to the app module's build.gradle file's dependencies section.

At this point the layout preview will break.

jasongisstl avatar Jan 16 '17 22:01 jasongisstl

I don't think It has anything to do with ConstraintLayout . The IDE cannot preview my preferences, just because they are customized. There is nothing I can do about it, except for reporting about it to Google, so this is what I did now: https://code.google.com/p/android/issues/detail?id=232320 Please star/comment about it, if you wish it to get more attention.

AndroidDeveloperLB avatar Jan 17 '17 07:01 AndroidDeveloperLB

Thank you very much for jumping on this so quickly!

I think this is a different issue. Apologies if I was too vague.

It is not that your custom preferences aren't shown in the preview, it is that including this library in a project (even if you do nothing with it) causes Android Studio to fail to preview ConstraintLayouts - it displays a (or several) 'No Such Field Error'(s).

Steps to reproduce:

  • Create a new project (it should include ConstraintLayout & AppCompat by default now), with a default blank activity.
  • View the layout xml file in Design view - note that it is displaying correctly.
  • Add maven { url 'https://jitpack.io' } to the Project's build.gradle file's repositories section.
  • Add compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:9' to the app module's build.gradle file's dependencies section.
  • Sync the project.
  • Go back to view the layout xml file in design view, and it will not display anything, giving the render.
  • Comment out compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:9' in the app module's build.gradle file - the design mode springs back into life.

androidstudiorenderissue

jasongisstl avatar Jan 17 '17 09:01 jasongisstl

OK, I will need to check it out. Maybe I just need to update the libraries my library use (supoprt library stuff).

AndroidDeveloperLB avatar Jan 17 '17 10:01 AndroidDeveloperLB

BTW, if you have minSdk set to 14 or above, you should consider using Google's solution: https://plus.google.com/+AndroidDevelopers/posts/9kZ3SsXdT2T Currently, it has the same issue of not animating the switchPreference, as I've got here. No idea why. I think it will solve your issue here, though.

AndroidDeveloperLB avatar Jan 17 '17 14:01 AndroidDeveloperLB

I've succeeded reproducing this issue, but it says that it's a known issue: maxthonsnap20170119160126

AndroidDeveloperLB avatar Jan 19 '17 14:01 AndroidDeveloperLB

Anyway, I've reported about this issue too: https://code.google.com/p/android/issues/detail?id=232553

AndroidDeveloperLB avatar Jan 19 '17 14:01 AndroidDeveloperLB