Is it insecure to keep admob ad-unit id in my apk?

Viewed 425

I've integrated admob in my app. For each different ad I used different ad unit id. For getting those ad-unit id I kept those id's in my string.xml file. If anyone decompiles my apk he can get those ids easily. So my question is, can anyone do something malicious with those id's? Should I keep those keys in server and fetch when needed?

1 Answers

The possibility of maliciously attacking via your AD-unit-ID is pretty slim. However, someone could still use your APP-ID and AD-unit-ID to generate an invalid traffic which leads your AdMob account suspended.

According to this document, you may put these IDs in your build.gradle file and automatically switch your test-AD-IDs / real-AD-IDs by selecting different build types.

Here is my code in app/build.gradle

buildTypes {
    debug {
        applicationIdSuffix ".debug"
        resValue "string", "app_name", "@string/app_name_debug"
        resValue "string", "ad_banner_id",   "ca-app-pub-3940256099942544/6300978111"  // test unit id
        resValue "string", "ad_rewarded_id", "ca-app-pub-3940256099942544/5224354917"  // test unit id
    }

    release {
        resValue "string", "app_name", "@string/app_name_release"
        resValue "string", "ad_banner_id",   "ca-app-pub-***/***"  // real ad unit id
        resValue "string", "ad_rewarded_id", "ca-app-pub-***/***"  // real ad unit id
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
    }
}
Related