Android Studio 3.2无法初始化类android.graphics.Typeface

时间:2018-05-14 08:15:56

标签: android android-layout android-studio

使用" CustomFontView"迁移到Android Studio 3.2布局后初始化时发出警告,无法预览

java.lang.NoClassDefFoundError: Could not initialize class android.graphics.Typeface
at android.graphics.Paint_Delegate.reset(Paint_Delegate.java:1256)
at android.graphics.Paint_Delegate.<init>(Paint_Delegate.java:1210)
at android.graphics.Paint_Delegate.nInit(Paint_Delegate.java:701)
at android.graphics.Paint.nInit(Paint.java)
at android.graphics.Paint.<init>(Paint.java:478)
at android.graphics.drawable.ColorDrawable.<init>(ColorDrawable.java:49)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:302)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:246)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:140)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:289)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:448)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:585)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

android.graphics.Typeface在库根文件夹

下可见

用途:

'com.android.tools.build:gradle:3.2.0-alpha14'

compileSdkVersion 27

buildToolsVersion "27.0.3"

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

目前,成功构建是使用以下版本的SDK和buildTools

buildToolsVersion "28.0.0-rc2"

compileSdkVersion 'android-P'

support库迁移到androidx

def x_version = '1.0.0-alpha1'
def x_constraint_version = '1.1.0'
dependencies {
   implementation "androidx.recyclerview:recyclerview:$x_version"
   implementation "androidx.appcompat:appcompat:$x_version"
   implementation "androidx.constraintlayout:constraintlayout:$x_constraint_version"
   implementation "androidx.coordinatorlayout:coordinatorlayout:$x_version"
   implementation "androidx.cardview:cardview:$x_version"
}