有谁知道出了什么问题?尝试从清单中检索版本代码时,我反复收到此错误:
04-19 15:09:34.778: W/ResourceType(29293): No package identifier when getting value for resource number 0x00000001
04-19 15:09:36.833: W/System.err(29293): android.content.res.Resources$NotFoundException: String resource ID #0x1
04-19 15:09:36.843: W/System.err(29293): at android.content.res.Resources.getText(Resources.java:242)
04-19 15:09:36.848: W/System.err(29293): at android.widget.Toast.makeText(Toast.java:304)
04-19 15:09:36.853: W/System.err(29293): at com.koeriers.standaard.actUpdate.onCreate(actUpdate.java:71)
04-19 15:09:36.863: W/System.err(29293): at android.app.Activity.performCreate(Activity.java:5206)
04-19 15:09:36.863: W/System.err(29293): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
04-19 15:09:36.868: W/System.err(29293): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
04-19 15:09:36.873: W/System.err(29293): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
04-19 15:09:36.878: W/System.err(29293): at android.app.ActivityThread.access$700(ActivityThread.java:140)
04-19 15:09:36.883: W/System.err(29293): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
04-19 15:09:36.888: W/System.err(29293): at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 15:09:36.893: W/System.err(29293): at android.os.Looper.loop(Looper.java:137)
04-19 15:09:36.898: W/System.err(29293): at android.app.ActivityThread.main(ActivityThread.java:4921)
04-19 15:09:36.898: W/System.err(29293): at java.lang.reflect.Method.invokeNative(Native Method)
04-19 15:09:36.903: W/System.err(29293): at java.lang.reflect.Method.invoke(Method.java:511)
04-19 15:09:36.908: W/System.err(29293): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
04-19 15:09:36.913: W/System.err(29293): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
04-19 15:09:36.918: W/System.err(29293): at dalvik.system.NativeStart.main(Native Method)
04-19 15:09:37.043: D/dalvikvm(29293): GC_CONCURRENT freed 211K, 14% free 9864K/11399K, paused 13ms+13ms, total 77ms
04-19 15:09:37.093: W/ResourceType(29293): Failure getting entry for 0x010802c0 (t=7 e=704) in package 0 (error -75)
这是我用来从清单文件中检索 versionCode 的代码:
int currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
当然还有我的清单文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp.default"
android:versionCode="1"
android:versionName="1.0" >
我希望你们能帮助我。
我的 onCreate 方法:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
TLogFile.appendLog("i", "UPDATER", "Updaten");
// setting some display
setContentView(R.layout.frmupdate);
TextView tv = new TextView(this);
tv.setText("Loading...");
// making sure the download directory exists
checkAndCreateDirectory("/downloads");
try {
int currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
Toast.makeText(this, currentVersion, Toast.LENGTH_LONG).show();
} catch (NameNotFoundException n) {
n.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
// executing the asynctask
new DownloadFileAsync().execute(fileURL);
}