gpt4 book ai didi

android - res/raw文件夹下的jar文件

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:58 29 4
gpt4 key购买 nike

我需要将第 3 方 jar 文件作为原始资源放在我的 apk 中的 res/raw 下。但是对于 Android Studio(我使用的是 1.3.1),该文件似乎从最终的 apk 中消失了。大概是因为 'jar' 的扩展。

我不能重命名它,也不希望它包含在 dex 类中。我的应用需要访问作为原始资源的 jar 运行时。

关于如何实现的任何建议(也许可以修改 gradle 任务)?

最佳答案

根据官方 Android 文档,您应该始终将 .jar 文件仅放在 /libs 文件夹下。

参见 official documentation ,

raw/

For arbitrary raw asset files. Saving asset files here is essentially the same as saving them in the assets/ directory. The only difference is how you access them. These files are processed by aapt and must be referenced from the application using a resource identifier in the R class. For example, this is a good place for media, such as MP3 or Ogg files.

libs/

Contains private libraries. Stored in the main application module.

.jar 文件放入/libs 文件夹后,您可以通过gradle.build 文件轻松引用它,

例如,我将这个 acra-4.6.2.jar 文件放在 /libs 文件夹中

enter image description here

并像这样在 gradle.build 文件中进行引用,

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/acra-4.6.2.jar')
}

关于android - res/raw文件夹下的jar文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32043172/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com