在< 25 sdk上运行时,应用程序崩溃

时间:2017-05-23 17:55:07

标签: java android gradle resources

我已经构建了一个应用程序,并且在设计过程中始终使用sdk 25在模拟器上进行测试。现在我使用sdk 24和23在模拟器上运行它并且它在没有停在任何断点(包括系统)的情况下崩溃那些)。 所以,下面是监测报告。我可以看到资源有问题,但我无法弄清楚到底是什么。 让我最困惑的是它在sdk 25上完美运行。

到目前为止,我已经使用AS工具清理了我的项目。

$ ionic build android --debug

[12:50:58]  typescript: D:/myApp/src/pages/home/home.ts, line: 6  MEM: 184.0MB
            Cannot find name 'require'.

       L6:  var sprintf = require('sprintf-js');
--------- beginning of crash
05-23 19:29:04.167 3037-3037/com.labfoodandfriends.walley E/AndroidRuntime:
    FATAL EXCEPTION: main
    Process: com.labfoodandfriends.walley, PID: 3037
    android.content.res.Resources$NotFoundException: Resource ID #0x7f040048
        at android.content.res.Resources.getValue(Resources.java:1351)
        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2774)
        at android.content.res.Resources.getLayout(Resources.java:1165)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
        at com.labfoodandfriends.walley.mFragments.TodayStats.onCreateView(TodayStats.java:53)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1984)
        at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:714)
        at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
        at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1391)
        at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:784)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
        at android.view.Choreographer$CallbackRecord.run(
05-23 19:34:04.196 3037-3037/com.labfoodandfriends.walley I/Process: Sending signal. PID: 3037 SIG: 9

2 个答案:

答案 0 :(得分:1)

这是一个XML错误。所以,断点不起作用。您的某个XML资源文件中缺少资源。

  

资源ID#0x7f040048

您可以在R.java文件中重新检查它(如果它存在与否)

此外,如果存在,请确保您已在适当的位置声明此ID。如果在声明之前在XML文件中访问此id。您可能会看到此错误。

答案 1 :(得分:0)

问题是我有一些仅为v25构建的布局。所以我创建了他们的副本,它现在正在工作。