After using ant build, I get some drawable ids mixed up when I am trying to assign them problematically(not in the xml).
I have an array that is holding some drawable ids:
int[]ids={R.drawable.pic1,R.drawable.pic2,R.drawable.pic3,R.drawable.pic4};
And when I try to assign them to an imageview a different drawable is displayed.
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.somelayout);
iv = (ImageView)findViewById(R.id.image);
iv.setBackgroundResource(ids[0]);
}
It doesn’t happen when I set the drawable in the xml, this works :
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/pic1" />
Try closing Eclipse and running
ant cleanfollowed byantfrom the command line. If that works, the most likely problem is that your ant script is building to the same directories as Eclipse, and if Eclipse is running while doing the ant build, it may detect changed files and run its own builds at the same time. This can cause some inconsistent results based on timing of the builds.In general, be sure that your ant scripts build to different directories from those that Eclipse uses. This includes the “gen” directory – use a separate one for ant.