Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 库插件::找不到库资源大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我目前正在将 Android库转换为Unity插件.
我已经走了很长的路,但是现在我已经陷入无法从Unity访问图书馆资源的地步.

应用程序运行正常,直到我实际从库调用视图.
这是我在那一刻得到的错误日志:

@H_874_11@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文件中.
>从Unity Android项目禁用setContentView()

有谁可以帮忙吗?
先感谢您!

[编辑]
我想我在这里发现了问题
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

@H_874_11@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 @R_450_8917@ own.

有谁知道与Unity3D一起解决这个问题的最佳解决方案是什么?

解决方法

实际上它是由Unity3D的一个不合适的后期打包过程引起的.它在aapt生成包含资源id的R类之前生成dex文件.所以你没有机会依赖静态资源id.

我已经通过为Unity3D编写一个编辑器插件解决了这个问题.但我现在无法释放它,因为它有问题而我现在太忙了,无法修复它.

但由于你的问题是移植代码.我建议你改变你的资源加载代码在java中采用Unity3D引起的这个问题.

@H_874_11@// context should be the activity of your unity3d application which raise the call to your plugin. // Loading String String myResString = context.getresources().getString( context.getresources().getIdentifier("sample_String","String",context.getPackagename())); // Loading image AlertDialog.builder tDialog = new AlertDialog.builder(context); tDialog.setIcon( context.getresources().getIdentifier("sample_icon","drawable",context.getPackagename()) );

大佬总结

以上是大佬教程为你收集整理的android – 库插件::找不到库资源全部内容,希望文章能够帮你解决android – 库插件::找不到库资源所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。