android studio测试时报错:no such instance field

原因:检查build.gradle文件中buildtypes/debug 是否打开了混淆

Android gradle的buildTypes内部配置

buildTypes {

    debug {

        // 服务器配置

        buildConfigField "String", "SERVERHEAD", "\"http://110.11.11.00/miaomiao/\""

        //是否混淆 minifyEnabled false

        zipAlignEnabled true

        shrinkResources false

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        signingConfig signingConfigs.debug

    }

    release {

    // 正式服务器

    buildConfigField "String", "SERVERHEAD", "\"http://miaomiao.com/miaomiao/\""

    //混淆

    minifyEnabled true

    zipAlignEnabled true//内存对齐

    // 移除无用的resource文件

    shrinkResources true

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    //签名 signingConfig signingConfigs.release

    }

}

你可能感兴趣的:(android studio测试时报错:no such instance field)