找不到资源ID? logcat的

时间:2014-05-13 22:04:16

标签: android android-resources android-logcat forceclose

这是我的坚果,我需要它解决,因为它一直在发生。

基本上当我从eclipse启动应用程序到我的手机时它不会打开,它只是强制关闭并且它正在执行它,因为LogCat说资源ID还没有被找到尽管事实如此。

我已经尝试了一切让它发挥作用,但为了防止我错过了一个技巧,我想问你很多!

由于

哦,这是Log

  05-13 22:56:01.291: E/AndroidRuntime(27580): FATAL EXCEPTION: main
    05-13 22:56:01.291: E/AndroidRuntime(27580): Process: com.simplistic.floating_equalizerpro, PID: 27580
05-13 22:56:01.291: E/AndroidRuntime(27580): android.content.res.Resources$NotFoundException: Resource ID #0x7f070008 type #0x12 is not valid
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:3231)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.content.res.XResources.loadXmlResourceParser(XResources.java:566)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.content.res.Resources.getLayout(Resources.java:1825)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.View.inflate(View.java:18366)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at com.simplistic.floating_equalizerpro.ui.EqualizerFragment.initUi(EqualizerFragment.java:115)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at com.simplistic.floating_equalizerpro.ui.EqualizerFragment.onViewCreated(EqualizerFragment.java:170)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:952)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:478)
05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.View.measure(View.java:17387)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.View.measure(View.java:17387)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.view.View.measure(View.java:17387)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.view.View.measure(View.java:17387)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.View.measure(View.java:17387)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.view.View.measure(View.java:17387)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2533)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.View.measure(View.java:17387)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2211)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1325)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1547)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at   android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1234)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6465)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
    05-13 22:56:01.291: E/AndroidRuntime(27580):    at android.view.Choreographer.doCallbacks(Choreographer.java:603)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.Choreographer.doFrame(Choreographer.java:573)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at android.os.Handler.handleCallback(Handler.java:733)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at android.os.Handler.dispatchMessage(Handler.java:95)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.os.Looper.loop(Looper.java:157)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at android.app.ActivityThread.main(ActivityThread.java:5356)
  05-13 22:56:01.291: E/AndroidRuntime(27580):  at java.lang.reflect.Method.invokeNative(Native Method)
   05-13 22:56:01.291: E/AndroidRuntime(27580):     at java.lang.reflect.Method.invoke(Method.java:515)
 05-13 22:56:01.291: E/AndroidRuntime(27580):   at com.android.internal.os.ZygoteInit$Me



    protected void initUi() {
    this.mEqualizerEnabled = (CheckBox) getView()
            .findViewById(R.id.equalizer_enabled);
    this.mBandsContainer = (LinearLayout) getView()
            .findViewById(R.id.equalizer);
    this.mMaxBandLevel = EqualizerApi.getMaxBandLevelRange();
    this.mMinBandLevel = EqualizerApi.getMinBandLevelRange();
    this.mBandsCount = EqualizerApi.getNumberOfBands();
    Integer integer = (this.mMaxBandLevel - this.mMinBandLevel);
    for (int i = 0; i < this.mBandsCount; ++i) {
        inflate = View.inflate(getActivity(), R.id.equalizer_bands, mBandsContainer);
    }
    for (int j = 0; j < this.mBandsCount; ++j) {
        VerticalSeekBar verticalSeekBar = this.getBandByIndex(j);
        verticalSeekBar.setMax(integer.intValue());
        verticalSeekBar.setId(j);
    }
    for (int k = 0; k < this.mBandsCount; ++k) {
        this.getBandTitleByIndex(k).setText(
                (this.getFreqValue(EqualizerApi.getBandFreq(k))));
    }
}

1 个答案:

答案 0 :(得分:1)

这些是我可以想象的错误:

1-在layout.xml中,你有一个这样的元素:

  <View    
   android:id="@+id/your_id"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

但你有这个:

  <View    
   android:id="@id/your_id"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

所以......你的_id元素没有添加到R.java中,这就是问题所在。

2-您正在使用RelativeLayout,并且您正在执行以下操作:

  <TextView
   android:id="@+id/your_id"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerVertical="true"
   android:layout_toLeftOf="@id/other_id"
   android:layout_toRightOf="@id/other_id2"
   android:visibility="invisible" >
  </TextView>

但是other_id或/和other_id2元素不存在,这就是问题所在。

3-也许您正在做错误的引用,例如......当您应该调用 R.layout.my_layout R.id.my_layout >反之亦然。

也许我错过了一些案例,但这些是我到目前为止所能想到的问题。

如果仍然无法解决问题,那么您应该搜索错误的资源。

  1. 在Eclipse中,打开&#34; gen&#34;夹
  2. 在该文件夹中,您会看到一个包裹 (com.simplistic.floating_equalizerpro我认为),展开它
  3. 打开R.java文件
  4. (CMD + F)或(CTRL + F)并搜索id#0x7f070008
  5. 注意资源名称,您应该知道代码中的位置 使用该资源......并修复它。