无法启动活动ComponentInfo android.view.InflateException:二进制XML文件行#49:错误导致类<unknown>

时间:2018-04-06 22:22:27

标签: android android-layout

我是android的新手。我试图从youtube教程构建一个项目,但在这个布局中我遇到了一些错误,无法解决它。有人在我的支持库中说我有问题但是我不明白该怎么做。

这是我的图书馆:

abstract class Base {
    companion object {
        inline fun <reified T : Base> create(f: () => T) : T { 
            val instance = f()
            // do something
            return instance // or something created from it
        }
    }
}

class A : Base() {
    companion object {
        fun create() : A = Base.create { A() }
    }
}

以下是错误日志

compile 'com.android.support:design:26.+'
compile 'com.cepheuen.elegant-number-button:lib:1.0.2'
compile 'com.android.support:design:26.+'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
testCompile 'junit:junit:4.12'
> FATAL EXCEPTION: main  Process: com.example.lol.smartwaiter, PID: 6821
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.example.lol.smartwaiter/com.example.lol.smartwaiter.FoodDetails}:
> android.view.InflateException: Binary XML file line #49: Error
> inflating class <unknown> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
> at android.app.ActivityThread.access$800(ActivityThread.java:151) at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
> at android.os.Handler.dispatchMessage(Handler.java:102) at
> android.os.Looper.loop(Looper.java:135) at
> android.app.ActivityThread.main(ActivityThread.java:5254) 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:903)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
> 
> 
> Caused by: android.view.InflateException: Binary XML file line #49:
> Error inflating class <unknown> at
> android.view.LayoutInflater.createView(LayoutInflater.java:633) at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
> at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at
> android.view.LayoutInflater.inflate(LayoutInflater.java:504) at
> android.view.LayoutInflater.inflate(LayoutInflater.java:414) at
> android.view.LayoutInflater.inflate(LayoutInflater.java:365) at
> android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
> at
> android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
> at
> com.example.lol.smartwaiter.FoodDetails.onCreate(FoodDetails.java:35)
> at android.app.Activity.performCreate(Activity.java:5990) at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
> at android.app.ActivityThread.access$800(ActivityThread.java:151)  at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
> at android.os.Handler.dispatchMessage(Handler.java:102) at
> android.os.Looper.loop(Looper.java:135)  at
> android.app.ActivityThread.main(ActivityThread.java:5254)  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:903)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)   
> 
> 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.rInflate(LayoutInflater.java:806)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:504)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:414)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:365)  at
> android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
> at
> android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
> at
> com.example.lol.smartwaiter.FoodDetails.onCreate(FoodDetails.java:35) 
> at android.app.Activity.performCreate(Activity.java:5990)  at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
> at android.app.ActivityThread.access$800(ActivityThread.java:151)  at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
> at android.os.Handler.dispatchMessage(Handler.java:102)  at
> android.os.Looper.loop(Looper.java:135)  at
> android.app.ActivityThread.main(ActivityThread.java:5254)  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:903)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
> 
> 
> Caused by: java.lang.NullPointerException: Attempt to invoke virtual
> method 'android.graphics.drawable.Drawable
> android.graphics.drawable.Drawable$ConstantState.newDrawable()' on a
> null object reference at
> android.graphics.drawable.LayerDrawable$ChildDrawable.<init>(LayerDrawable.java:961)
> at
> android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:1007)
> at
> android.graphics.drawable.RippleDrawable$RippleState.<init>(RippleDrawable.java:922)
> at
> android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:913)
> at
> android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:94)
> at
> android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:912)
> at
> android.graphics.drawable.RippleDrawable.mutate(RippleDrawable.java:899)
> at android.view.View.applyBackgroundTint(View.java:16425) at
> android.view.View.setBackgroundDrawable(View.java:16294) at
> android.support.design.widget.FloatingActionButton.access$001(FloatingActionButton.java:68)
> at
> android.support.design.widget.FloatingActionButton$ShadowDelegateImpl.setBackgroundDrawable(FloatingActionButton.java:822)
> at
> android.support.design.widget.FloatingActionButtonLollipop.setBackgroundDrawable(FloatingActionButtonLollipop.java:69)
> at
> android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:179)
> at
> android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:151)
> 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.rInflate(LayoutInflater.java:806)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:504)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:414)  at
> android.view.LayoutInflater.inflate(LayoutInflater.java:365)  at
> android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
> at
> android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
> at
> com.example.lol.smartwaiter.FoodDetails.onCreate(FoodDetails.java:35) 
> at android.app.Activity.performCreate(Activity.java:5990)  at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
> at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
> at android.app.ActivityThread.access$800(ActivityThread.java:151)  at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
> at android.os.Handler.dispatchMessage(Handler.java:102)  at
> android.os.Looper.loop(Looper.java:135)  at
> android.app.ActivityThread.main(ActivityThread.java:5254)  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:903)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

0 个答案:

没有答案