2

I tried all the solution like creating new project or change sdk version or add dependencies but it still gives rendering error. It only gives error in activityMain.xml layout file not in app_bar_main.xml or not in content_main.xml or not in nav_header_main.xml so I don't know what to do next.

enter image description here

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Alap Dhruva
  • 31
  • 1
  • 2
  • 3
    Possible duplicate of [Exception raised during rendering: Unable to locate mode 0](http://stackoverflow.com/questions/40161934/exception-raised-during-rendering-unable-to-locate-mode-0) – Clay Oct 26 '16 at 16:00
  • Is a bug of Android 25: Duplicate here :[change the compilation library](http://stackoverflow.com/questions/40203220/rendering-issue-in-xml-preview-unable-to-locate-mode-0) – Divait Nov 07 '16 at 16:43

5 Answers5

0

its because of the version of your build tool : 25.0.0
go to gralde.build and change it to 24.1.1
and let it download this version of build tool : 24.2.1


then change these codes :
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'

to :
compile 'com.android.support:appcompat-v7:24.2.1'<br> compile 'com.android.support:design:24.2.1'

then sync once !
Booom its correct now :-)

Mehdi Karimi
  • 528
  • 4
  • 25
  • 2
    Hum, downgrading is not a solution IMO. What if you need the new widget, BottomNavigationView, that comes with 25.0.0? – Redwarp Nov 01 '16 at 16:35
  • 2
    @Redwarp The only REAL solution is to wait until Google releases an update. Until then, you can downgrade in order to view your renders. If you need a specific widget, then feel free to keep the current version. However you won't be able to render views that are affected by the bug. – Chad Mx Nov 01 '16 at 19:50
  • @ChadMx yeah, I currently render with... instant run and running the app ;-) But downgrading is not a solution. It would be if support library 25 was only a point release, supposed to only fix issues. But it adds stuff. – Redwarp Nov 02 '16 at 09:45
0

I know what the problem is about, but I don't know how to solve it..

In your layout, when you have a ScrollView with a RecyclerView inside it, the layout just not render... If you comment the RecyclerView and do the refresh on layout, it should render again.

Here I need to comment the RecyclerView, so I can edit my layout =). And yes, the update to build.tools 25 came with this bug, I think it is a bug. Or google saying to you not use lists inside ScrollViews hehe.

Heitor
  • 83
  • 1
  • 7
0

In build.gradle file, change

compile 'com.android.support:design:25.0.0'

to

compile 'com.android.support:design:24.2.1'

Its worked for me

nguyencse
  • 1,028
  • 9
  • 17
0

This is a known bug issue and already solved in Issue 225753:

You need to update to support library 25.0.1:

compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
0

Another approach is just switch to version 25.1.0.This bug has been fixed in this build version.

oshurmamadov
  • 264
  • 8
  • 14