没有合适的资源?快使用搜索试试~ 我知道了~
首页Android 判断是开发debug模式,还是发布release模式的方法
如下所示: public class LogUtils { public static boolean APP_DBG = false; // 是否是debug模式 public static void init(Context context){ APP_DBG = isApkDebugable(context); } /** * 但是当我们没在AndroidManifest.xml中设置其debug属性时: * 使用Eclipse运行这种方式打包时其debug属性为true,使用Eclipse导出这种方式打包时其debug属性为法false. * 在使用ant打包
资源详情
资源评论
资源推荐

Android 判断是开发判断是开发debug模式模式,还是发布还是发布release模式的方法模式的方法
如下所示:如下所示:
public class LogUtils {
public static boolean APP_DBG = false; // 是否是debug模式
public static void init(Context context){
APP_DBG = isApkDebugable(context);
}
/**
* 但是当我们没在AndroidManifest.xml中设置其debug属性时:
* 使用Eclipse运行这种方式打包时其debug属性为true,使用Eclipse导出这种方式打包时其debug属性为法false.
* 在使用ant打包时,其值就取决于ant的打包参数是release还是debug.
* 因此在AndroidMainifest.xml中最好不设置android:debuggable属性置,而是由打包方式来决定其值.
*
* @param context
* @return
* @author SHANHY
* @date 2015-8-7
*/
public static boolean isApkDebugable(Context context) {
try {
ApplicationInfo info= context.getApplicationInfo();
return (info.flags&ApplicationInfo.FLAG_DEBUGGABLE)!=0;
} catch (Exception e) {
}
return false;
}
}
项目开发中,我们根据debug属性来输出日志。
但是有些时候我们想在给公司的测试机上安装的release版本也输出日志,那么这个时候我们到 AndroidManifest.xml 中的
application 标签中添加属性强制设置debugable即可,如下:
<application android:debuggable="true" tools:ignore="HardcodedDebugMode"
....
.... />
init 方法在客户端的第一个Activity的onCreate方法中执行一下即可。
以上这篇Android 判断是开发debug模式,还是发布release模式的方法就是小编分享给大家的全部内容了,希望能给大家一个参
考,也希望大家多多支持软件开发网。
您可能感兴趣的文章您可能感兴趣的文章:Android APK使用Debug签名重新打包 Eclipse更改默认Debug签名


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0