简体   繁体   English

忽略来自Android APK的文件

[英]Ignoring files from Android APK

Is it possible to ignore files from being packaged into the Android APK? 是否可以忽略文件被打包到Android APK中? For instance, I have my .psd files in the same folder as their .png counterparts, and all the .psd files get packaged up. 例如,我将.psd文件放在与.png对应文件夹相同的文件夹中,并且所有.psd文件都打包完毕。

I know I can move them outside of the folder, but I like having them in all together and would prefer not to if possible 我知道我可以将它们移到文件夹之外,但我喜欢将它们放在一起,如果可能的话,我不愿意这样做

This is actually supported in the Android Asset Packaging Tool (AAPT). Android Asset Packaging Tool(AAPT)实际上支持这一点。

I always put my psd-like files in the resource directories like this: 我总是将类似psd的文件放在资源目录中,如下所示:

/res/drawable/_pre_production/ic_launcher.psd

Any _pre_production directory will not be added to the APK. 任何_pre_production目录都不会添加到APK。

With this approach they're in a sub-directory of the actual images' directory, but I don't see the problem with that. 使用这种方法,它们位于实际图像目录的子目录中,但我没有看到它的问题。 It is still neatly organized. 它仍然整齐有序。 ;) ;)

An Ant script will do the trick. Ant脚本可以解决这个问题。 If you are using proguard, even that script may be good enough for u. 如果您正在使用proguard,即使该脚本对您来说也足够好。

Use the Maven Android Plugin and declare your resources with a matching pattern that excluded the relevant file types you dont want added (eg * / .psd). 使用Maven Android插件并使用匹配的模式声明您的资源,该模式排除了您不想添加的相关文件类型(例如* / .psd)。 Check out the documentation for the resource plugin and look at the M aven Android Plugin Samples project .. specifically the MorseFlash application I created and the resource plugin related setup. 查看资源插件文档 ,查看M aven Android插件示例项目 ..特别是我创建的MorseFlash应用程序以及与资源插件相关的设置。

您可以尝试使用maven android插件并在构建阶段添加一些逻辑。

如果您使用的是Eclipse,请右键单击该文件并选择“从构建路径中排除”

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

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