简体   繁体   English

Android如何从APK文件中排除某些文件夹

[英]Android how to exclude certain folder from apk file

I create android project and add compile dependencies that have other platforms tools/files/libs and I need to remove(exclude) this file from my .apk file. 我创建了一个android项目并添加了具有其他平台工具/文件/库的编译依赖项,我需要从.apk文件中删除(排除)此文件。 You can see the folder I want to remove on this screenshot: 您可以在此屏幕截图上看到我要删除的文件夹: 在此处输入图片说明

  1. If it's a dependency that you included but no longer need, remove the dependency in gradle. 如果您已包含但不再需要它,请在gradle中删除该依赖。
  2. If it's required by some other dependency, then you can't remove it or you'll break the functionality. 如果其他依赖项需要它,则不能将其删除,否则将破坏功能。
  3. If it's a transitive dependency and you're sure you don't need it, consider using the minify features of proguard . 如果它是传递依赖项,并且您确定不需要它,请考虑使用proguard缩小功能

android {
  buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                'proguard-rules.pro'
    }
  }
  ...
}

Also, keep in mind that that if you go the proguard route, then you need to re-evaluate your dependencies and make special exceptions for any code that uses reflection. 另外,请记住,如果您采用了proguard路线,则需要重新评估依赖关系,并对使用反射的任何代码进行特殊例外处理。

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

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