Advertiser assets outside native ad view.

291 views
Skip to first unread message

Rakesh Kumar

unread,
Aug 12, 2025, 5:14:50 AM8/12/25
to Google Mobile Ads SDK Developers
For few cards I am getting that advertiser assets outside the native ad view. 
for few its working fine. 
While in both the cases I am using same layout. And 80-90% time it's giving no issue but some times getting issue.
But not able to find out which assets are out side the native view. 
Please help on this, this is a very long pending issue. 

Screenshot 1: (with_issue)
Screenshot 2: (no_issue)


with_issue.png
no_issue.png

Rakesh Kumar

unread,
Aug 12, 2025, 6:35:44 AM8/12/25
to Google Mobile Ads SDK Developers
Attaching more details :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/videoItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@color/black">

<com.google.android.gms.ads.nativead.NativeAdView
android:id="@+id/native_ad_view"
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/ad_attribution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/advertisement"
android:textSize="12sp"
android:textColor="@color/black"
android:fontFamily="@font/poppins_medium"
android:includeFontPadding="false"
android:layout_margin="@dimen/_4dp"
android:paddingHorizontal="@dimen/_6dp"
android:layout_marginBottom="@dimen/_2dp"
android:background="@drawable/round_corner_rectangle_8"
android:backgroundTint="@color/status_bar_color_F2F9FB"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.gms.ads.nativead.MediaView
android:id="@+id/ad_media"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/ad_attribution"
app:layout_constraintBottom_toTopOf="@+id/ad_body"
android:layout_gravity="center_horizontal" />

<TextView
android:id="@+id/ad_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_16dp"
android:layout_marginBottom="@dimen/margin_8dp"
android:fontFamily="@font/poppins_semibold"
android:textColor="@color/white"
android:textSize="12sp"
app:layout_constraintBottom_toTopOf="@+id/ad_icon"
app:layout_constraintStart_toStartOf="parent"
tools:text="Ads body" />

<ImageView
android:id="@+id/ad_icon"
android:layout_width="@dimen/margin_40dp"
android:layout_height="@dimen/margin_40dp"
android:layout_marginStart="@dimen/margin_12dp"
android:layout_marginBottom="@dimen/margin_12dp"
android:adjustViewBounds="true"
android:paddingBottom="5dp"
app:layout_constraintBottom_toTopOf="@+id/ad_call_to_action"
app:layout_constraintStart_toStartOf="parent" />


<LinearLayout
android:id="@+id/professionNameLL"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_8dp"
android:elevation="@dimen/margin_12dp"
android:orientation="vertical"
android:padding="@dimen/margin_4dp"
app:layout_constraintBottom_toBottomOf="@+id/ad_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ad_icon"
app:layout_constraintTop_toTopOf="@+id/ad_icon">

<TextView
android:id="@+id/ad_headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/sans_semibold"
android:maxLength="20"
android:maxLines="1"
android:textColor="@color/white"
android:textSize="@dimen/text_size_14sp"
tools:text="Rakesh Rajput" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/ad_advertiser"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="@font/poppins_regular"
android:gravity="bottom"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold" />

<RatingBar
android:id="@+id/ad_stars"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.5"
android:textSize="@dimen/text_size_10sp"
android:theme="@style/RatingBar" />

<TextView
android:id="@+id/ad_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_regular"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:textColor="@color/white"
android:textSize="12sp" />

<TextView
android:id="@+id/ad_store"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/poppins_regular"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:textColor="@color/white"
android:textSize="12sp" />

</LinearLayout>

</LinearLayout>

<Button
android:id="@+id/ad_call_to_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_16dp"
android:layout_marginBottom="@dimen/margin_8dp"
android:gravity="center"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.gms.ads.nativead.NativeAdView>

</androidx.constraintlayout.widget.ConstraintLayout>





val adView: NativeAdView = adContainer.findViewById(R.id.native_ad_view)
// Some assets are guaranteed to be in every UnifiedNativeAd.
adView.mediaView =
adView.findViewById(R.id.ad_media)
adContainer.visibility = VISIBLE

// Register the view used for each individual asset.
adView.headlineView = adView.findViewById(R.id.ad_headline)
adView.bodyView = adView.findViewById(R.id.ad_body)
adView.callToActionView =
adView.findViewById(R.id.ad_call_to_action)
adView.iconView = adView.findViewById(R.id.ad_icon)
adView.advertiserView = adView.findViewById(R.id.ad_advertiser)
adView.priceView = adView.findViewById(R.id.ad_price)
adView.starRatingView = adView.findViewById(R.id.ad_stars)
adView.storeView = adView.findViewById(R.id.ad_store)
(adView.headlineView as TextView?)?.text = nativeAd.headline
(adView.bodyView as TextView?)?.text = nativeAd.body
(adView.callToActionView as Button?)?.text = nativeAd.callToAction

// These assets aren't guaranteed to be in every UnifiedNativeAd, so it's important to
// check before trying to display them.
val icon = nativeAd.icon
if (icon == null) {
adView.iconView?.visibility = INVISIBLE
} else {
(adView.iconView as ImageView?)?.setImageDrawable(icon.drawable)
adView.iconView?.visibility = VISIBLE
}
if (nativeAd.price.isNullOrEmpty()) {
adView.priceView?.visibility = GONE
} else {
adView.priceView?.visibility = VISIBLE
(adView.priceView as TextView?)?.text = nativeAd.price
}
if (nativeAd.store.isNullOrEmpty()) {
adView.storeView?.visibility = GONE
} else {
adView.storeView?.visibility = VISIBLE
(adView.storeView as TextView?)?.text = nativeAd.store
}
if (nativeAd.starRating == null) {
adView.starRatingView?.visibility = INVISIBLE
} else {
(adView.starRatingView as RatingBar?)?.rating = nativeAd.starRating!!.toFloat()
adView.starRatingView?.visibility = VISIBLE
}
if (nativeAd.advertiser == null) {
adView.advertiserView?.visibility = INVISIBLE
} else {
(adView.advertiserView as TextView?)!!.text = nativeAd.advertiser
adView.advertiserView?.visibility = VISIBLE
}

// Assign native ad object to the native view.
adView.setNativeAd(nativeAd)
issue.png

Mobile Ads SDK Forum Advisor

unread,
Aug 12, 2025, 2:19:49 PM8/12/25
to rakeshr...@gmail.com, google-adm...@googlegroups.com

Hi ,

Thank you for contacting the Mobile Ads SDK Support team.

Kindly note that Native Validator automatically alerts you of certain policy violations in your UI through an overlay popup next to the ad.

I have tested our Sample project with the provided code changes but unfortunately we are unable to reproduce the issue which you reported. Instead we got a different warning issue “MediaView is too small for video” caused by “0dp” value for the MediaView height constraint. After changing this constraint to” wrap_content” it worked as  expected without any issues.

Additionally, please note that you are using the  “native_ad_view” id  from adContainer. This id  contains the native_ad_view and was inflated properly?. Could you try setting the  NativeAdView as the root of the layout. 

Could you confirm whether the mentioned issue is reproducible in our sample project after integrating your code? If yes,please share the sample project which replicates the issue via reply to author option? for further investigation.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=500Ht00001syoRRIAY&entry.80707362=00329663

2. Fill out all fields, and attach your file(s).

3. Please reply back to this thread when you have uploaded your file(s). Please do not share this link.


Thanks,
 
Google Logo Mobile Ads SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-08-12 18:18:29Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01syoRR:ref" (ADR-00329663)



Mobile Ads SDK Forum Advisor

unread,
Aug 19, 2025, 12:03:37 PM8/19/25
to rakeshr...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for sharing the screen recordings. As mentioned earlier, I have again tested our Sample project with the updated code changes you provided. Unfortunately we are unable to reproduce the reported issue. Could you confirm whether the mentioned issue is reproducible in our sample project after integrating your code? If yes, please share the sample project which replicates the issue via reply to author option? for further investigation.



If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=500Ht00001syoRRIAY&entry.80707362=00329663

2. Fill out all fields, and attach your file(s).

3. Please reply back to this thread when you have uploaded your file(s). Please do not share this link.


Thanks,
 
Google Logo Mobile Ads SDK Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-08-19 16:01:57Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01syoRR:ref" (ADR-00329663)



Rakesh Kumar

unread,
Aug 20, 2025, 5:25:27 AM8/20/25
to Mobile Ads SDK Forum Advisor, google-adm...@googlegroups.com
I have uploaded a screen recording of the issue. in above link. 
Also adding update code. 

                    android:layout_gravity="center_vertical"
                    android:orientation="horizontal">

<TextView
android:id="@+id/ad_advertiser"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="@font/poppins_regular"
                        android:textColor="@color/white"
android:textSize="@dimen/text_size_12sp"
                        android:layout_marginStart="@dimen/_4dp"
                        android:textColor="@color/white"
android:textSize="12sp" />

</LinearLayout>

</LinearLayout>

<Button
android:id="@+id/ad_call_to_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_16dp"
android:layout_marginBottom="@dimen/margin_8dp"
android:gravity="center"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.gms.ads.nativead.NativeAdView>

</androidx.constraintlayout.widget.ConstraintLayout>
Reply all
Reply to author
Forward
0 new messages