【问题标题】:Why is there an error when setting the value of "debugging" to "true" in android application?为什么在android应用程序中将“debugging”的值设置为“true”时会出错?
【发布时间】:2014-10-05 13:21:46
【问题描述】:

每当我在我的 android 应用程序中将“debugging”的值设置为“true”时,都会出现错误。 错误的描述是:“避免对调试模式进行硬编码;将其保留允许调试和发布版本自动分配一个”。

【问题讨论】:

    标签: android debugging android-manifest


    【解决方案1】:

    从清单中删除 android:debuggable="true"

    首先,您可能不需要它。即使使用 Eclipse,正常的 IDE 构建也可以自动调试,就像模拟器上的任何进程一样。出于安全原因,在生产硬件上的发布版本不可调试,这是您想要的。

    如果您需要更多的灵活性,并且您正在使用 Android Studio/Gradle for Android,请在 build.gradle 中设置自定义构建类型以模拟您的其他场景。默认的debug 构建类型将使应用程序可调试;默认的 release 构建类型会使您的应用程序不可调试。自定义构建类型可以使用debuggable 语句来说明它们应该做什么:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.12.2'
        }
    }
    
    apply plugin: 'com.android.application'
    
    dependencies {
    }
    
    android {
        compileSdkVersion 19
        buildToolsVersion "19.1.0"
    
        defaultConfig {
            versionCode 2
            versionName "1.1"
            minSdkVersion 14
            targetSdkVersion 18
        }
    
        signingConfigs {
            release {
                storeFile file('HelloConfig.keystore')
                keyAlias 'HelloConfig'
                storePassword 'laser.yams.heady.testy'
                keyPassword 'fw.stabs.steady.wool'
            }
        }
    
        buildTypes {
            debug {
              applicationIdSuffix ".d"
              versionNameSuffix "-debug"
            }
    
            release {
                signingConfig signingConfigs.release
            }
    
            mezzanine.initWith(buildTypes.release)
    
            mezzanine {
                applicationIdSuffix ".mezz"
                debuggable true
            }
        }
    }
    

    在这里,我说我的mezzanine 自定义构建类型应该是可调试的,通过其定义中的debuggable true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多