How to check if APK is signed or “debug build”?

后端 未结 10 1949
我在风中等你
我在风中等你 2020-11-29 16:34

As far as I know, in android \"release build\" is signed APK. How to check it from code or does Eclipse has some kinda of secret defines?

I need thi

10条回答
  •  星月不相逢
    2020-11-29 16:50

    To check the debuggable flag, you can use this code:

    boolean isDebuggable =  ( 0 != ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
    

    Kotlin:

    val isDebuggable = 0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE
    

    For more information, please see Securing Android LVL Applications.

    Alternatively, if you're using Gradle correctly, you can check if BuildConfig.DEBUG is true or false.

提交回复
热议问题