开发者社区> 问答> 正文

在Android 5.0和Android 6.0上膨胀类androidx.constraintlay

在Pixel XL API 21上运行我的应用程序,出现以下错误。


E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.samprojects.sickvibes, PID: 4322
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.samprojects.sickvibes/com.samprojects.sickvibes.SplashActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
    at android.app.ActivityThread.access$800(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
    at com.samprojects.sickvibes.SplashActivity.onCreate(SplashActivity.java:88)
    at android.app.Activity.performCreate(Activity.java:5937)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
    at android.app.ActivityThread.access$800(ActivityThread.java:144) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5221) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
    at android.view.LayoutInflater.createView(LayoutInflater.java:607)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
    at com.samprojects.sickvibes.SplashActivity.onCreate(SplashActivity.java:88) 
    at android.app.Activity.performCreate(Activity.java:5937) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
    at android.app.ActivityThread.access$800(ActivityThread.java:144) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5221) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
 Caused by: android.content.res.Resources$NotFoundException: Resource "com.samprojects.sickvibes:drawable/rounded_corner_b" (7f0800e1)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0800e1 a=-1 r=0x7f0800e1}
    at android.content.res.Resources.loadDrawableForCookie(Resources.java:2390)
    at android.content.res.Resources.loadDrawable(Resources.java:2330)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
    at android.view.View.<init>(View.java:3730)
    at android.view.ViewGroup.<init>(ViewGroup.java:491)
    at android.view.ViewGroup.<init>(ViewGroup.java:487)
    at android.view.ViewGroup.<init>(ViewGroup.java:483)
    at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:569)
    at java.lang.reflect.Constructor.newInstance(Native Method) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
    at com.samprojects.sickvibes.SplashActivity.onCreate(SplashActivity.java:88) 
    at android.app.Activity.performCreate(Activity.java:5937) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
    at android.app.ActivityThread.access$800(ActivityThread.java:144) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5221) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

我尝试了以下建议的解决方案,但它们没有解决错误。我的XML不包含的任何用法class androidx.constraintlayout.ConstraintLayout,因为该错误表明我的XML仅包含class androidx.constraintlayout.widget.ConstraintLayout。我还实现了最新的依赖关系implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'

建议的解决方案:意见建议_0,建议_1

有人可以帮忙吗?

展开
收起
Puppet 2020-01-18 10:09:50 974 0
1 条回答
写回答
取消 提交回答
  • 感谢@Rodrigo Queiroz,我得以找出问题所在。真正的问题是Caused by: android.content.res.Resources$NotFoundException: Resource "com.samprojects.sickvibes:drawable/rounded_corner_b" (7f0800e1) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0800e1 a=-1 r=0x7f0800e1}。我的可绘制对象存储在我的“ drawable-v24”文件夹中,而不是我的“ drawable”文件夹中。我将所有矢量素材资源从“ drawable-v24”剪切并粘贴到“ drawable”文件夹中……该应用目前运行良好。

    2020-01-18 10:10:00
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载