I've hit a very frustrating issue with one of my apps.
I have a splashscreen activity which loads up some initial data for my app then launches the main activity and finishes itself.
Once main activity is running, I background the app by pressing the home key and then kill the process for my app.
When I relaunch my app, the splashscreen tries to run but fails as soon as I try to access any of the fields in my R.java file:
For example, I immediately try to set the text of a textview like so:
((TextView)findViewById(R.id.splash_tv_1)).setText(application.getLanguage().pleasewait);
This throws the following exception:
06-29 11:18:14.661: ERROR/AndroidRuntime(21427): java.lang.NoSuchFieldError: com.pagesuite.android.reader.framework.R$id.splash_tv_1
Then when I launch it again it's fine.
I get the same behaviour if I kill the app using a TaskKiller tool (something I know a lot of users will be naively using I suspect) or if the OS kills my process.
Any ideas?
EDIT:
Just noticed in the logcat, just before onCreate() of this activity executes, the following is logged:
06-29 11:18:14.571: WARN/dalvikvm(21427): VFY: unable to resolve static field 1945 (splash_logo) in Lcom/pagesuite/android/reader/framework/R$id;
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: replacing opcode 0x60 at 0x0000
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: dead code 0x0002-0010 in Lcom/pagesuite/android/reader/framework/activities/PS_Splashscreen;.loadLogoImg (Lcom/pagesuite/android/reader/framework/xml/appsettings/PS_AppSettings;)V
06-29 11:18:14.571: DEBUG/dalvikvm(21427): DexOpt: couldn't find static field
06-29 11:18:14.571: WARN/dalvikvm(21427): VFY: unable to resolve static field 1946 (splash_tv_1) in Lcom/pagesuite/android/reader/framework/R$id;
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: replacing opcode 0x60 at 0x0000
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: dead code 0x0002-0039 in Lcom/pagesuite/android/reader/framework/activities/PS_Splashscreen;.setLanguage ()V
06-29 11:18:14.571: DEBUG/dalvikvm(21427): DexOpt: couldn't find static field
06-29 11:18:14.571: WARN/dalvikvm(21427): VFY: unable to resolve static field 1946 (splash_tv_1) in Lcom/pagesuite/android/reader/framework/R$id;
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: replacing opcode 0x60 at 0x0000
06-29 11:18:14.571: DEBUG/dalvikvm(21427): VFY: dead code 0x0002-0020 in Lcom/pagesuite/android/reader/framework/activities/PS_Splashscreen;.setTextColors ()V
These are the three instances where I try to access R.id in my class.
One thing to note is that I do call:
setContentView(R.layout.ps_splashscreen);
and it seems to run this line fine, so it is the R.id's specifically that seem to be missing.
EDIT: Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/splash_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/splash_tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please wait"
android:textColor="@color/white"
android:textSize="20dip" />
<TextView
android:id="@+id/splash_tv_2"
android:layout_marginTop="20dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loading..."
android:textColor="@color/white" />
</LinearLayout>
i had the same problem and it gave me
DexOpt: couldn't find static field
error because i had two layout xml files with the same name, one in an external library one in the project. I don't know if this can be useful to others :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With