在布局中使用自定义Kotlin视图“无法找到以下类”

我遇到了一个问题,包括XML布局文件中的自定义Kotlin视图。 代码如下:

class CustomView: RelativeLayout { /** * Programmatic constructor */ constructor(aVariable: Boolean, context: Context): super(context) { ... } /** * XML constructor */ @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defStyle: Int = 0): super(context, attributeSet, defStyle) { ... } } 

XML

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" /> <com.turingtechnologies.materialscrollbar.CustomView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> </RelativeLayout> 

然后布局预览器抱怨:

“缺课 –

无法找到以下类: com.turingtechnologies.materialscrollbar.CustomView (修复构建路径,编辑XML,创建类)“

注意:这是AS 3.0 beta 3

确认错误https://issuetracker.google.com/issues/62255811 。 修复应该会出现在Android Studio的下一个版本中。