Android NoSuchField error in R.java after process is killed
<p>I've hit a very frustrating issue with one of my apps.</p>

<p>I have a splashscreen activity which loads up some initial data for my app then launches the main activity and finishes itself.</p>

<p>Once main activity is running, I background the app by pressing the home key and then kill the process for my app.</p>

<p>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:</p>

<p>For example, I immediately try to set the text of a textview like so:</p>

<pre><code>((TextView)findViewById(R.id.splash_tv_1)).setText(application.getLanguage().pleasewait);
</code></pre>

<p>This throws the following exception:</p>

<pre><code>06-29 11:18:14.661: ERROR/AndroidRuntime(21427): java.lang.NoSuchFieldError: com.pagesuite.android.reader.framework.R$id.splash_tv_1
</code></pre>

<p>Then when I launch it again it's fine.</p>

<p>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.</p>

<p>Any ideas?</p>

<p>EDIT:</p>

<p>Just noticed in the logcat, just before onCreate() of this activity executes, the following is logged:</p>

<pre><code>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
</code></pre>

<p>These are the three instances where I try to access R.id in my class. </p>

<p>One thing to note is that I do call:</p>

<pre><code>setContentView(R.layout.ps_splashscreen);
</code></pre>

<p>and it seems to run this line fine, so it is the R.id's specifically that seem to be missing.</p>

<p>EDIT:
Here is the layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
</code></pre>

<p></p>

<pre><code>&lt;LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:orientation="vertical" 
    android:gravity="center"&gt;

    &lt;ImageView
        android:id="@+id/splash_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" /&gt;


    &lt;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" /&gt;

    &lt;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" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p></p>
