The Gradle build error AAPT: error: unbound prefix occurs during Android Asset Packaging Tool (AAPT2) compilation when an XML layout, menu, or vector drawable uses attribute prefixes like android: or app: without declaring the corresponding XML namespace (xmlns:android or xmlns:app) on the root tag.
Root XML Namespace Fix Example
<!-- CORRECT: All XML Namespaces declared on ROOT Layout Element -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Child elements can now safely use android: and app: attributes without AAPT errors -->
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
</LinearLayout>
Comments and corrections