Android Studio:排除资源sourceSets下的资源文件 [英] Android Studio: Exclude resource file under resources sourceSets

查看:94
本文介绍了Android Studio:排除资源sourceSets下的资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 android studio 作为 IDE 开发一个 android 应用程序.

I'm developing an android app using android studio as IDE.

我的问题是:
如何在构建APK的过程中排除某个目录下的某些文件?

My question is:
How to exclude certain files under certain directory during the process of building APK?

就我而言,我想从构建中排除一些图像,因为我的项目中使用的那些文件被指定为从网络应用程序内下载,而在开发过程中我希望在布局中引用它们.

In my case, I want to exclude some images from building since the those files used in my project are designated to be downloaded from network in-app while during the development I hope to refer them in the layout.

经过谷歌搜索,我找到了一些解决方案:
Gradle 1.2:排除资源源集下的目录
如何使用 Gradle 和 Android 从资源中排除文件工作室?
参考 来自 gradle.org

After googling, I found some solutions:
Gradle 1.2: Exclude directory under resources sourceSets
How to exclude file from resources using Gradle and Android Studio?
And reference from gradle.org

然后我在 build.gradle 中提出了我的解决方案:

Then I came up my solution in build.gradle:

sourceSets {
    main {
        resources.exclude '**/drawable/*'
        res.exclude '**/drawable/*'
    }
}

但是不行,res/drawable/下的图片还是显示出来(下载前).

But it doesn't work, the image under res/drawable/ still shows up(before downloading).

Android Studio 版本目前为 0.8.4.
任何想法将不胜感激.

The Android Studio version is currently 0.8.4.
Any idea would be appreciated.

推荐答案

Android 源集当前不支持排除路径.您可以在错误 https://code.google.com/p/android/issues/中跟踪此问题详细信息?id=64957

Exclude paths aren't currently supported for Android sourceSets. You can track this at bug https://code.google.com/p/android/issues/detail?id=64957

这是因为Android sourceSets 与Java sourceSets 不同;它们是 Android 插件中的自定义实现,不会自动获取其表兄弟的所有功能.这需要专门为 Android 实现,目前还没有实现.

This is happening because Android sourceSets aren't the same as Java sourceSets; they're a custom implementation in the Android plugin, and don't automatically pick up all the features of their cousins. This will need to be specially implemented for Android, and it hasn't been done yet.

这篇关于Android Studio:排除资源sourceSets下的资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆