2014-07-10 27 views

回答

2

我建议您命名的文件是这样的:

file_debug.properties => debug file 
file.properties   => release file 

,并在代码中做到这一点:

final String mode = isDebugMode() ? "_debug" : ""; 
final String suffix = mode + ".properties"; 

String fileName = "file" + suffix; //either file_debug.properties or file.properties 

private boolean isDebugMode() { 
    return android.os.Debug.isDebuggerConnected(); //is being debugged via ADB 
    // or 
    //return 0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE); //can be debugged, but maybe not at the moment 
} 
0

除了可以在你的代码检测调试模式和选择要去哪个分支,你也可以定制你的ant构建过程来改变像pre_compile这样的属性文件。

我们现在在开发时有一个配置文件,我们有一个独立的生成机器来构建发行版本,并且在生成机器中,我们将属性文件更改为发行版本。

相关问题