为什么我的真实phone上ImageView的内容是空的?

Why is the content of the ImageView empty on my real phone?

我尝试将可绘制对象设置到 ImageView 中。来源取决于月份中的两位数天数(存储在 today 中)。我的 API-等级是 17 (The Fairphone 1).

在虚拟设备上我可以看到图片。但是当我在我的真实 phone 上安装应用程序时,ImageBox 在那里但是是空的(白色)。

这是我设置图片的代码:

ImageView image = (ImageView) findViewById(R.id.startImg);
String uri = "s_"+Integer.parseInt(today);
int imageResource = getBaseContext().getResources().getIdentifier(uri, "drawable", getPackageName());
image.setImageResource(imageResource);

这是我的布局文件:

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textColor="@color/colorAccent"
        android:textSize="20dp"
        android:paddingBottom="16dp"
        android:id="@+id/textView"
        android:textAlignment="center"
        android:textStyle="bold"
        android:typeface="serif" />
    <ImageView
        android:contentDescription="Bild"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:id="@+id/startImg" />
    <GridView
        android:id="@+id/DatesGrid"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="3"
        >
    </GridView>
</LinearLayout>

LogCat什么也没说。

但我在 API-22 层(The Fairphone 2)的 Phone 上检查了应用程序。现在应用程序因错误 imageResource 而崩溃。

问:为什么我在虚拟设备上可以看到图片,但在真实设备上看不到?

感谢大家的提示。我现在可以解决这个问题了。

存在存储分配错误,只能在不同的 API 级别 (22) 上调试。 Level 17 没有给出任何错误。我现在缩小了图像。这也解释了为什么它适用于具有不同存储设置的虚拟设备。