我的一个应用程序遇到了一个非常令人沮丧的问题.
我有一个splashscreen活动,它为我的应用程序加载一些初始数据,然后启动主要活动并完成自己.
主活动运行后,我通过按主页键来设置应用程序,然后终止我的应用程序.
当我重新启动我的应用程序时,启动画面会尝试运行但是一旦我尝试访问我的R.java文件中的任何字段就会失败:
例如,我立即尝试设置textview的文本,如下所示:
((TextView)findViewById(R.id.splash_tv_1)).setText(application.getLanguage().pleasewait);
Run Code Online (Sandbox Code Playgroud)
这会引发以下异常:
06-29 11:18:14.661: ERROR/AndroidRuntime(21427): java.lang.NoSuchFieldError: com.pagesuite.android.reader.framework.R$id.splash_tv_1
Run Code Online (Sandbox Code Playgroud)
然后,当我再次启动它时,它很好.
如果我使用TaskKiller工具杀死应用程序,我会得到相同的行为(我知道很多用户会天真地使用我怀疑的东西)或者操作系统会杀死我的进程.
有任何想法吗?
编辑:
刚刚在logcat中注意到,就在此活动的onCreate()执行之前,会记录以下内容:
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
Run Code Online (Sandbox Code Playgroud)
这是我尝试在班上访问R.id的三个实例.
需要注意的一点是我打电话:
setContentView(R.layout.ps_splashscreen);
Run Code Online (Sandbox Code Playgroud)
它看起来很好地运行这条线,所以特别是Rid似乎缺失了.
编辑:这是布局:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
Mar*_*ark 13
我有同样的问题,它给了我
DexOpt: couldn't find static field
Run Code Online (Sandbox Code Playgroud)
错误,因为我有两个具有相同名称的布局xml文件,一个在项目的外部库中.我不知道这对其他人是否有用:)
| 归档时间: |
|
| 查看次数: |
1608 次 |
| 最近记录: |