1. 程式人生 > >android錯誤之android.content.res.Resources$NotFoundException:

android錯誤之android.content.res.Resources$NotFoundException:

錯誤:android.content.res.Resources$NotFoundException: String resource ID #0x1

原因:一般發生在引數 int resId 錯誤,你把String賦值給int的resId,所以編譯器找不到正確的resource於是報錯。

最簡單的例子,檢查一下你的Toast.makeText()啊textView.setText啊之類的函式,這種函式通常有幾個過載,如:

textView.setText(CharSequence text);

textView.setText(int resId);

......

如果不小心將一個int值傳給了它,那它不會顯示該int值,而是跑到工程下去找一個對應的resource的id,當然是找不到的,於是就報錯啦。

比如我這裡是這樣的:

count.setText(incall.getCount());

incall.getCount();返回的是一個int值,直接setText肯定不行啊,就是上面的錯誤型別,

解決辦法就是

count.setText(String.valueOf(incall.getCount()));

或者

count.setText(incall.getCount() + "");

超級簡單,但是如果注意不到就讓人抓狂,明明沒錯嘛!你報個妹的錯!再錯我砸了你!!!

息怒..........

作者:jason0539

相關推薦

android錯誤android.content.res.Resources$NotFoundException:

錯誤:android.content.res.Resources$NotFoundException: String resource ID #0x1 原因:一般發生在引數 int resId 錯誤,你把String賦值給int的resId,所以編譯器找不到正確的resou

【BUG】android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi/toolbar_line.png from

設備 cati des dpi com rgs inflater from argument SafeGod在coolpad(4.0)上執行。登陸進去的設備列表界面遇到的問題。三星和索尼沒有這個問題。 06-24 15:23:06.897: E/AndroidRun

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070058 android-studio 3.0 from canary 5 to canary 6

time cat -1 int pre lac patch check caused 我升級android-studio到了3.0 canary 6打包編譯安裝出現如下錯誤: 07-11 13:00:39.523 8913-8913/dcpl.com.myapplic

android.content.res.Resources$NotFoundException: String resource ID #0x11

resource sin native pla int ble invoke args traversal 在練習數據綁定時,出現以下錯誤 FATAL EXCEPTION: main

android.content.res.Resources$NotFoundException: String resource ID #0xd

執行出現上述異常。貼上異常部分的程式碼: viewHolder.tvAssortment.setText(list.get(position).getAssortment()); 其中tvAssortment是TextView型別,list.get(position).getAssort

android.content.res.Resources$NotFoundException: Resource String id #0x0

android 執行中發生異常 文中說找不到String資源#0x0,於是解決辦法是去R檔案中找值為#0x0的項。結果當然是找不到。(R檔案在build->generated->source->r->包名->R) 最後通過註釋掉可能出錯的行排查出結果。

android.content.res.Resources$NotFoundException: Resource ID #0x23ecb2

在平時開發中肯定會遇到android.content.res.Resources$NotFoundException資源找不到的問題,最常見的就是setText()傳入了一個int型別的資料,遇到這種問題很好解決,把int型別資料換成string就行了,原因太簡單了不再解釋。但是在開發中

我遇到的android.content.res.Resources$NotFoundException的解決方案

07-29 16:19:18.101 29570-29570/? E/AndroidRuntime: FATAL EXCEPTION: main

android.content.res.Resources$NotFoundException: Resource ID XXX問題解決

最近遇到專案報這個錯誤,但是資源卻是存在的,在網上找了資料,clean,型別轉換,工程佔用,等等方法都試過了,均不能解決,最後發現,原來是這個原因。 這行報錯,但實際上我是有這個資源的。 但是,xml檔案旁邊有一個標誌:land,我不知道是什麼意思。 於是,我重新new

安卓 AlertDialog 報 android.content.res.Resources$NotFoundException 的坑

最近專案中想簡單實現一個兩個專案的Dialog,卻一直報如題的錯誤。 起因是這樣的: 寫了個彈出以文字作為內容的AlertDialog類,想做一個簡單彈窗選擇。 public class SimpleDialogUtils { public

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/***

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/* 1、log顯示 01-01 09:04:12.245 D/AndroidRuntime( 2938

解決android.content.res.Resources NotFoundException的一個方法

在android開發中會用一些資源,這些資源以不同形式存在,比如說圖片,xml等,android為這些不同型別的資源統一編號,生成資源類R 。如下:public final class R { public static final class anim { public

android.content.res.Resources$NotFoundException: String resource ID #0x1

對接介面完之後出現這樣bug,setText設定出現問題, 仔細看了下才明白字串轉換異常,,這個setText從後臺去的是數字, 而現在設定的setText確實字串,然後自己在取值後臺添加了+"" ,

已解決錯誤: 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object re

11-18 16:02:26.490: W/WindowManager(312): Token{420aaa08 ActivityRecord{41c5fef8 com.rk.jcz/.IndexActivity}} failed creating starting window11-18 16:02:26.

調用android的getColor()方法出現 java.lang.NoSuchMethodError: android.content.res.Resources.getColor

sdn targe drawable ava source 添加 andro content 鏈接 1.java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable/getColor或者 jav

Android錯誤--Error retrieving parent for item: No resource found that matches the given name 'Theme.A

方法 minimum vertical 宋體 popu pac fim wid bre 錯誤提示:error: Error retrieving parent for item: No resource found that matches the given name

Android常見錯誤android widget LinearLayout 4375f248 that was or

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Android錯誤 Requires VIBRATE permission

允許應用程式向用戶詞典中寫入新詞 寫入Google線上同步設定 讀取使用者的社交資訊流 允許程式寫簡訊 允許程式讀取或寫入系統設定 允許應用程式讀取或寫入安全系統設定 允許程式寫入個人資料資料 8.com.android.browser.permission.WRITE_HISTORY_BOO

Android Wearandroid穿戴式設備應用開發平臺

san 選擇框 hour sam family hat 2.6 potential rep Android Wear於2014年03月19日公布,並有Moto 360和LG watch兩款產品。眼下源代碼還沒有開放。可是開發人員能夠下載它的Ima

Android開發Android studio 3.2.1配置androidannotations

androidannotations,Butterknife 元件等大大的提高了開發效率,但在配置androidannotations 的時候卻出現了問題,根據根據網上的資料配置 annotationProcessor “org.androidannotations:androidannot