Android:如何从其他Android应用程序访问资源文件夹

Kam*_*mal 5 xml android android-resources

我在我的应用程序中集成了jar.jar包含图像和字符串.我能够以编程方式从该jar访问图像和字符串,但我需要从jar文件中访问资源

编程方式:

imgView.setImageResource(com.example.jartesting.R.drawable.call_icon); 
Run Code Online (Sandbox Code Playgroud)

上面的代码工作正常.

XML

<ImageView
    android:id="@+id/imagesample"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true"
    android:background="@com/example/jartesting/drawable/call_icon"/>
Run Code Online (Sandbox Code Playgroud)

上面的xml代码无效.它显示错误:不允许字符串类型

任何人都可以帮我解决这个问题吗?

提前致谢

Kin*_*ses 0

JAR 仅包含代码;您无法以这种方式访问​​资源。

例如:Google 将自己的“Google Play Services Library”作为 Android 库项目进行分发,其中包含 lib 目录中 JAR 文件中的二进制代码、res 目录中的资源以及 src 目录中的 UnusedStub 类。如果有更好的方法可行,我认为他们会使用它。

虽然 Android Studio 仍处于测试阶段,但它包含对AAR文件的(有缺陷的)支持。看来这最终将成为要走的路。