Custom Layout Inflation with Fragments in Robolectric not working

后端 未结 4 1183
刺人心
刺人心 2021-01-12 10:34

When inflating a layout in a Fragment, with the LayoutInflater, i am getting this exception:

 ./res/layout/locations_list.xml line #-1 (sorry, not yet implem         


        
4条回答
  •  无人及你
    2021-01-12 11:25

    The last version of Robolectric (3.0-Snapshot) has some problems with customized views.

    To fix that, do the follow:

    1. In the module app where your code is, create a file called project.properties, at the same level as AndroidManifest.xml
    2. Fill the content with reference to the class folder of build. e.g. for StaggeredGridView:

    android.library.reference.1=../../build/intermediates/exploded-aar/com.etsy.android.grid/library/1.0.5

    Here you must check three things:

    • There should be one line per reference
    • Each reference has one number (1, 2, 3), which should be increase by one each time
    • The version number folder at the end must match with the version number in your build.gradle file.

    You have an example of project working here: https://github.com/jiahaoliuliu/RobolectricSample/blob/master/app/src/main/project.properties

提交回复
热议问题