我目前正在将 Android 库转换为 Unity 插件。我已经走了很长一段路,但现在我被困在无法从 Unity 访问图书馆资源的地步。
该应用程序运行良好,直到我真正从库中调用一个视图。这是我当时收到的错误日志:
12-12 13:37:36.495: W/ResourceType(32155): getEntry failing because entryIndex 1 is beyond type entryCount 1
12-12 13:37:36.495: W/ResourceType(32155): Failure getting entry for 0x7f030001 (t=2 e=1) in package 0 (error -2147483647)
12-12 13:37:36.500: D/AndroidRuntime(32155): Shutting down VM
12-12 13:37:36.500: W/dalvikvm(32155): threadid=1: thread exiting with uncaught exception (group=0x4109a2a0)
12-12 13:37:36.505: E/AndroidRuntime(32155): FATAL EXCEPTION: main
12-12 13:37:36.505: E/AndroidRuntime(32155): android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.content.res.Resources.getValue(Resources.j ava:1026)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.content.res.Resources.loadXmlResourceParse r(Resources.java:2131)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.content.res.Resources.getLayout(Resources. java:865)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.view.LayoutInflater.inflate(LayoutInflater .java:394)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.view.LayoutInflater.inflate(LayoutInflater .java:352)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.mycompany.mylibrary.components.AndroidWebViewD ialog.<init>(AndroidWebViewDialog.java:140)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.mycompany.mylibrary.FunctionAndroidLibrary.Sho wDialog(FunctionAndroidLibrary.java:163)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.mycompany.mylibrary.FunctionAndroidLibrary.but tonREGISTER(FunctionAndroidLibrary.java:94)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.mycompany.myUnityProjectAndroidLibraryTest$1.r un(AndroidLibraryTest.java:78)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.os.Handler.handleCallback(Handler.java:615 )
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.os.Handler.dispatchMessage(Handler.java:92 )
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.os.Looper.loop(Looper.java:137)
12-12 13:37:36.505: E/AndroidRuntime(32155): at android.app.ActivityThread.main(ActivityThread.jav a:4898)
12-12 13:37:36.505: E/AndroidRuntime(32155): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 13:37:36.505: E/AndroidRuntime(32155): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:1006)
12-12 13:37:36.505: E/AndroidRuntime(32155): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:773)
12-12 13:37:36.505: E/AndroidRuntime(32155): at dalvik.system.NativeStart.main(Native Method)
- 这些资源实际存在于库
.jar
文件中。 setContentView()
已从 Unity Android 项目中禁用
有谁能帮忙吗?先感谢您!
[编辑] 我想我在这里找到了问题: http ://tools.android.com/recent/dealingwithdependenciesinandroidprojects
Important change: We have changed the way Library Projects generate and package R classes:
The R class is not packaged in the jar output of Library Projects anymore.
Library Project do not generate the R class for Library Projects they depend on. Only main application projects generates the Library R classes alongside their own.
有谁知道结合 Unity3D 解决这个问题的最佳解决方案是什么?