我正在尝试使用Gradle配置一个包含一些外部库的项目.使用Gradle我可以使用Build Variants为主应用程序设置不同的环境配置(在配置文件中有一个类),这样我就可以根据这些变量执行代码.
问题是我如何为图书馆项目做同样的事情?我为这个项目创建了这个库,我想为不同的场景设置不同的Build Variants.
例如:在库中,当在调试模式下运行时,然后打印所有日志,以便我可以在开发时看到它们.在发布模式下不要.
文件结构:
src ----- > debug -> java -> config -> PlayerEnvConfig
main -> com.mypackagename -> etc...
release -> java -> config -> PlayerEnvConfig
Run Code Online (Sandbox Code Playgroud)
debug中的代码:package config;
/**
* Environment configuration for Release
*/
public final class PlayerEnvConfig {
public static final boolean USE_REPORTING = true;
public static final boolean USE_ANALYTICS = true;
public static final boolean USE_LOGGING = false;
public static final boolean USE_DEBUG_LOGGING = false;
public static final boolean USE_DEBUGING = false;
}
Run Code Online (Sandbox Code Playgroud)
发布代码:
package …Run Code Online (Sandbox Code Playgroud) 是否有可能配置Gradle构建几个Android apk文件,其中每个只使用一个资源类型文件夹?
我的意思是:
我知道我可以在构建之前简单地删除某些文件夹,但如果我可以"自动化"它会很好.
是否可以使用gradle"flavors"?
我使用以下语句在我的android应用程序中包含了opencv:
compile group: 'org.bytedeco', name: 'javacv', version: '0.11'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.11-0.11', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.11-0.11', classifier: 'android-x86'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.6.1-0.11', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.6.1-0.11', classifier: 'android-x86'
Run Code Online (Sandbox Code Playgroud)
现在仅使用了四分之二,这既浪费空间,又可能浪费速度。有没有办法只加载/编译属于体系结构的库?我已经阅读了针对不同处理器体系结构的Gradle android build,但是该库使用libs文件夹,因此具有自己的include。我有所有通过gradle导入的库。