问题描述
过去几个月我一直在学习 Android,并且一直使用 Eclipse Juno 作为我的 IDE.
I've been learning Android over the past few months and have been using Eclipse Juno as my IDE.
我正在尝试迁移到 Android-Studio,想知道如何从构建路径中排除"一些我尚未完成的类?
I am trying to migrate to Android-Studio and wonder how I can "exclude from build path" some of the classes I have yet to complete?
在 Eclipse 中,直接右键单击即可.我在 Studio 中找不到对它的任何引用.
In Eclipse, it was straight forward right click. I can't find any reference to it in Studio.
推荐答案
AFAIK IntelliJ 允许排除包.打开项目结构(Linux 中的 Ctr+Alt+Shift+S)> 模块 > 源选项卡.
AFAIK IntelliJ allows to exclude packages. Open Project Structure (Ctr+Alt+Shift+S in Linux) > Modules > Sources Tab.
但是,如果您只想排除一个类,请使用 Gradle 构建文件.
However if you would like to exclude only one class use Gradle build file.
Android Studio 使用 Gradle,因此在 build.gradle 文件中添加排除您的类的 android 配置自定义 SourceSet,例如:
Android Studio uses Gradle so in build.gradle file add inside android configuration custom SourceSet that excludes your class e.g:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
packageName "org.homelab.lab"
testPackageName "org.homelab.lab.test"
}
sourceSets {
main {
java {
exclude '**/SomeExcludedClass.java'
}
}
androidTest {
java {
exclude '**/TestSomeExcludedClass.java'
}
}
}
}
这篇关于Android Studio 从构建中排除类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!