库插件::找不到资源库 [英] Library plugin :: Library resources not found

查看:369
本文介绍了库插件::找不到资源库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在转换一个Android库到一个统一的插件。 我已经很长的路要走,但现在我卡在那里的图书馆的资源不能统一访问点。

I'm currently converting an Android Library to a Unity plugin. I got a long way already, but now I'm stuck on the point where the resources of the Library cannot be accessed from Unity.

应用程序被运行良好,直到我真正称之为从库中查看。 下面是错误日志中我得到的那一刻:

The application is running fine, until I actually call a view from the library. Here's the error log I'm getting at that moment:

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)

  • 在这些资源在物理上是美元的的函数库p $ psent 的.jar 文件。
  • 的setContentView()是从Unity Android项目禁用
    • These resources are physically present in the library .jar file.
    • setContentView() is disabled from the Unity Android project
    • 任何人谁可以帮帮忙? 预先感谢您!

      Anyone who can help out? Thank you in advance!

      我想我找到了问题就在这里: http://tool​​s.android.com/recent/dealingwithdependenciesinandroidprojects

      I think I found the problem here: 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的最佳解决方案?

      Does anyone know what is the best solution to solve this in combination with Unity3D?

      推荐答案

      其实它造成的Unity3D的inproper后期包装过程。它生成DEX文件之前AAPT产生R个类,其中包含资源ID 。那么有没有机会让你依靠静态的资源ID。

      Actually it's caused by an inproper post packaging process of Unity3D.It generate the dex file before aapt generate R class which contains resource id.So there is no chance for you to rely on static resource id.

      我已经写一个编辑器插件Unity3D.But我不能释放它,因为现在它的车和我太忙了,解决它目前解决了这个问题。

      I have solved this problem by writing an editor plugin for Unity3D.But I cannot release it now since it's buggy and I'm too busy to fix it at the moment.

      但由于您的问题,建议你改变你的资源加载code在java中采用这一问题所造成的Unity3D是移植了codeI。

      But due to your problem is porting the code.I suggest you change your resource loading code in java to adopt this problem caused by Unity3D.

      // 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())
      );
      

      这篇关于库插件::找不到资源库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆