Android Studio/Java – AAPT: error: attribute adUnitID Not Found

Okay, So I’ve been beating my head against the desk for two days trying to resolve this problem and I’m at a loss. Hoping it’s something simple, but not sure.

I have an Android project making use of Google AdMob. I’ve followed all of the instructions from the AdMob developer site. When building my project it fails with the following error:

Task :app:processDebugResources FAILED
AGPBI: {“kind”:”error”,”text”:”Android resource linking failed”,”sources”:[{“file”:”/Users/user12345/Developer/Android Studio Projects/MyApp/app/src/main/res/layout/activity_main.xml”,”position”:{“startLine”:213}}],”original”:”ERROR: /Users/user12345/Developer/Android Studio Projects/MyApp//app/src/main/res/layout/activity_main.xml:214: AAPT: error: attribute adUnitID (aka com.someorg.MyApp.debug:adUnitID) not found.n “,”tool”:”AAPT”}

Execution failed for task ‘:app:processDebugResources’.

A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Android resource linking failed
ERROR: /Users/user12345/Developer/Android Studio Projects/MyApp/app/src/main/res/layout/activity_main.xml:214: AAPT: error: attribute adUnitID (aka com.someorg.myapp.debug:adUnitID) not found.

Clearly it’s pointing at the XML file. In my XML, this is what I have:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".MainActivity">

<com.google.android.gms.ads.AdView
    android:id="@+id/ad_view"
    android:layout_width="0dp"
    android:layout_height="75dp"
    android:layout_marginStart="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="16dp"
    android:backgroundTint="#000000"
    ads:adSize="BANNER"
    ads:adUnitID="@string/banner_ad_unit_id"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent">
    
</com.google.android.gms.ads.AdView>
</androidx.constraintlayout.widget.ConstraintLayout>

For some reason the resource linker isn’t finding adUnitID. This my app-level build.gradle file:

android {
namespace 'com.someorg.myapp'
compileSdk 34

defaultConfig {
    applicationId "com.someorg.myapp"
    minSdkVersion 24
    targetSdkVersion 34
    versionCode 7
    versionName '1.0.7'
    multiDexEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
    buildConfig true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
        signingConfig signingConfigs.debug
        debuggable false
    }
    debug {
        applicationIdSuffix ".debug"
        debuggable true
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.11.0"))
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'androidx.activity:activity:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.retrofit2:converter-jackson:2.7.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
implementation 'com.google.android.gms:play-services-ads:23.3.0'
implementation 'com.google.android.gms:play-services-ads-base:23.3.0' 
}
}

And this is the portion of the Manifest.XML file that contains the :

<meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-################~##########"/>

(I have redacted the app-id in the above)

I have no idea what to do at this point. I might try building a new sample project and see if I can get just an adview working.

2

Per Mike M. – the problem was a capital D in this line of XML:

ads:adUnitID="@string/banner_ad_unit_id"

which I changed to:

ads:adUnitId="@string/banner_ad_unit_id"

And this resolved the problem.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật