从库访问资源会导致运行时崩溃

时间:2019-05-01 17:14:03

标签: android android-library

我有一个项目,并将其转换为模块库,并在主项目中使用了它

该项目使用黄油刀绑定库

一切正常,并且存在编译问题,一旦应用在我的设备上运行,我就开始在运行时遇到以下崩溃

2019-05-01 19:03:21.760 29300-29300/com.sbs16.ensofia E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sbs16.ensofia, PID: 29300
    android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class im.vector.view.HomeSectionView
    Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class im.vector.view.HomeSectionView
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
        at android.view.LayoutInflater.createView(LayoutInflater.java:652)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
        at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126)
        at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95)
        at com.sbs16.ensofia.base.BaseFragment.onCreateView(BaseFragment.kt:28)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0e00b0
        at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:202)
        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2968)
        at android.content.res.Resources.getLayout(Resources.java:1984)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:425)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
        at android.view.View.inflate(View.java:22188)
        at im.vector.view.HomeSectionView.setup(HomeSectionView.java:109)
        at im.vector.view.HomeSectionView.<init>(HomeSectionView.java:79)

我可以访问代码中的所有资源,但是我不知道为什么当我使用它会导致崩溃

任何人都可以帮忙吗?

0 个答案:

没有答案