0
我已經爲F#採用了Xamarin OpenGL示例應用程序,並試圖從XML加載(網格)數據。我已將XML文件添加到Resources/values
,並將其生成操作設置爲AndroidResource
,但是當我嘗試讀取它時遇到異常。嘗試加載XML資源時發生異常
我使用這個F#代碼嘗試讀取文件:
context.Resources.GetXml Resource_String.n
其中context
傳遞到GLView1
類型MainActivity
的對象。
我得到的例外是:
08-03 12:18:23.931 V/GLCube (29315): ***** at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in <filename unknown>:0
08-03 12:18:23.931 V/GLCube (29315): at Android.Content.Res.Resources.GetXml (Int32 id) [0x00000] in <filename unknown>:0
08-03 12:18:23.931 V/GLCube (29315): at AndroidOpenGLFSharp.GLView1..ctor (AndroidOpenGLFSharp.MainActivity context) [0x00000] in <filename unknown>:0
08-03 12:18:23.931 V/GLCube (29315): --- End of managed exception stack trace ---
08-03 12:18:23.931 V/GLCube (29315): android.content.res.Resources$NotFoundException: File 8 from xml type xml resource ID #0x7f040000
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2351)
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2306)
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.Resources.getXml(Resources.java:983)
08-03 12:18:23.931 V/GLCube (29315): at androidopenglfsharp.MainActivity.n_onCreate(Native Method)
08-03 12:18:23.931 V/GLCube (29315): at androidopenglfsharp.MainActivity.onCreate(MainActivity.java:30)
08-03 12:18:23.931 V/GLCube (29315): at android.app.Activity.performCreate(Activity.java:5133)
08-03 12:18:23.931 V/GLCube (29315): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-03 12:18:23.931 V/GLCube (29315): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-03 12:18:23.931 V/GLCube (29315): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-03 12:18:23.931 V/GLCube (29315): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-03 12:18:23.931 V/GLCube (29315): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-03 12:18:23.931 V/GLCube (29315): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 12:18:23.931 V/GLCube (29315): at android.os.Looper.loop(Looper.java:137)
08-03 12:18:23.931 V/GLCube (29315): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-03 12:18:23.931 V/GLCube (29315): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 12:18:23.931 V/GLCube (29315): at java.lang.reflect.Method.invoke(Method.java:525)
08-03 12:18:23.931 V/GLCube (29315): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-03 12:18:23.931 V/GLCube (29315): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-03 12:18:23.931 V/GLCube (29315): at dalvik.system.NativeStart.main(Native Method)
08-03 12:18:23.931 V/GLCube (29315): Caused by: java.io.FileNotFoundException: 8
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:488)
08-03 12:18:23.931 V/GLCube (29315): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2333)
08-03 12:18:23.931 V/GLCube (29315): ... 18 more
08-03 12:18:24.001 V/PhoneStatusBar(1201): setLightsOn(true)
08-03 12:18:24.021 V/GLCube (29315): Loading with default settings
我在做什麼錯?