简体   繁体   English

如何将自定义资产添加到.apk 文件中?

[英]How to add add custom assets into .apk file?

I need to have some files in android assets folder, how can I add them using QtCreator/QMake?我需要在 android 资产文件夹中有一些文件,如何使用 QtCreator/QMake 添加它们?

Assuming you have the following structure in your source directory:假设您的源目录中有以下结构:

foo.pro
extra_data/file1
extra_data/file2
…

Adding the following to foo.pro should deploy the extra_data folder to assets://extra_data (exact path might differ, cannot verify right now) in the APK:将以下内容添加到 foo.pro 应将 extra_data 文件夹部署到 APK 中的 assets://extra_data (具体路径可能不同,目前无法验证):

folder_01.source = extra_data
folder_01.target = extra_data
DEPLOYMENTFOLDERS += folder_01

If you are developing the application, then simply copy/paste the files in assets folder.如果您正在开发应用程序,则只需将文件复制/粘贴到 assets 文件夹中。

But if your application is already built and available as .apk file then you cannot modify any of its content.但是,如果您的应用程序已经构建并可作为.apk文件使用,则您无法修改其任何内容。

Copying files to /5.2.0/android_armv7/src/android/java/assets did the trick将文件复制到 /5.2.0/android_armv7/src/android/java/assets 就可以了

  • decompile the apk using apktool on pc or Apktool M for android.使用 pc 上的 apktool 或用于 android 的 Apktool M 反编译 apk。
  • add your files to the decompiled apk将您的文件添加到反编译的 apk
  • compile and sign your apk again.再次编译并签署您的 apk。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM