NotFoundException: String resource ID
-
android.content.res.Resources$NotFoundException: String resource ID #0x64
-
情景还原:
Toast.makeText(TestActivity.this, all.size(), Toast.LENGTH_SHORT).show();
- 源码分析:
情景一:public static Toast makeText(Context context, @StringRes int resId, @Duration int duration)
情景二:public static Toast makeText(Context context, CharSequence text, @Duration int duration)
- 源码分析:
之所以会出现这种情况,就是因为第二个参数既可以传String
也可以传int
类型,但是int
类型必须为@String
中定义的字符串对应的id
值。而此时,第二个参数传递的事all
集合的长度,在id文件中肯定找不到对应的String
,所以会出现运行时错误。
Failed to load the JNI shared library
- 注意jdk位数
网友评论