-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Native Ad not showing Icon because MaxNativeAdViewBinder's setIconContentViewId is protected #675
Comments
Hi @linversion I tested the code snippet you shared and have not been able to reproduce the issue. Could you reproduce the issue in our demo app and share a screenshot showing the issue you are seeing? |
Hi @NanaAmoah , here is how I reproduce the issue in kotlin demo app.
//app build.gradle
if (isLocalAppLovinWorkspace) {
implementation(project(":Android-SDK"))
} else {
implementation("com.applovin:applovin-sdk:12.5.0@aar")
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>
<ImageView
android:id="@+id/icon_image_view"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:contentDescription="icon" />
<FrameLayout
android:id="@+id/icon_content_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<FrameLayout
android:layout_width="26dp"
android:layout_height="15dp"
android:id="@+id/options_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
</FrameLayout>
<ImageView
android:id="@+id/ad_icon"
android:layout_width="27dp"
android:layout_height="18dp"
app:layout_constraintStart_toEndOf="@id/icon_image_view"
app:layout_constraintTop_toTopOf="@id/icon_image_view"
android:layout_marginStart="7dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title_text_view"
tools:text="Test Ad: "
app:layout_constraintStart_toEndOf="@id/ad_icon"
app:layout_constraintTop_toTopOf="@id/ad_icon"
app:layout_constraintBottom_toBottomOf="@id/ad_icon"
android:layout_marginStart="8dp"
/>
<!-- <FrameLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:id="@+id/star_rating_view"-->
<!-- android:visibility="gone"-->
<!-- />-->
<TextView
android:id="@+id/advertiser_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/title_text_view"
app:layout_constraintTop_toTopOf="@id/title_text_view"
tools:text="Flood-it"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/body_text_view"
app:layout_constraintStart_toStartOf="@id/ad_icon"
app:layout_constraintEnd_toStartOf="@id/cta_button"
app:layout_constraintTop_toBottomOf="@id/ad_icon"
android:layout_marginTop="5dp"
tools:text="Text text tesxt texge tegn tejogne gegegn gegoentete tee nnn ted tedgn tete"
android:maxLines="2"
android:ellipsize="end"
android:layout_marginEnd="5dp"
android:textSize="11sp"
/>
<!-- <FrameLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:id="@+id/media_view_container"-->
<!-- android:visibility="gone"-->
<!-- />-->
<Button
android:layout_width="76dp"
android:layout_height="wrap_content"
android:id="@+id/cta_button"
android:text="GO"
android:background="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
// ManualNativeLateBindingAdActivity
private fun createNativeAdView(): MaxNativeAdView {
val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.applovin_native_banner)
.setTitleTextViewId(R.id.title_text_view)
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.icon_image_view)
.setOptionsContentViewGroupId(R.id.options_view)
.setCallToActionButtonId(R.id.cta_button)
.build()
return MaxNativeAdView(binder, this)
}
the icon view can not show but if i set the iconContentViewId by reflection // ManualNativeLateBindingAdActivity
private fun createNativeAdView(): MaxNativeAdView {
val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.applovin_native_banner)
.setTitleTextViewId(R.id.title_text_view)
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.icon_image_view)
.setOptionsContentViewGroupId(R.id.options_view)
.setCallToActionButtonId(R.id.cta_button)
.build()
val iconContentViewId = binder.javaClass.getDeclaredField("iconContentViewId")
iconContentViewId.isAccessible = true
iconContentViewId.set(binder, R.id.icon_content_view)
return MaxNativeAdView(binder, this)
} |
Thanks @linversion. Can you please share the project which reproduces the issue here? |
@NanaAmoah bro I already said the project I used was the Applovin Max Demo App-Kotlin,just add your sdk key and native ad unit ID,follow the step I mentioned before |
@linversion could you double check that you are setting the correct package name, SDK key and ad unit ID in the demo app? A mismatch in your credentials will result in the issue you are seeing. To verify that you are using the correct package name and SDK key, tap "Launch Mediation Debugger". You should see your package name under "App Info" and all the ad unit IDs created for that app under "View Ad Units". I am only able to reproduce your issue in our demo app with mismatched credentials so if after double checking, you are still reproducing the issue, please share the demo app project where the issue is reproducible here. |
Hi @lovestart, could you confirm that you are setting the correct package name, SDK key and ad unit ID in the demo app? If after this you are still encountering the issue, please send us the demo app project where this is reproducible. |
I set the correct package name, SDK key, and ad unit ID in the Applovin demo app, but still have the same problem. In addition, I think it has little to do with setting your own SDK key, because in the same environment, it works fine to display Native ads through the Templates API, but it doesn't work when you enter Native through the Manual API. Through code tracking, I came to the same conclusion as @linversion , that it can only be displayed if setIconContentViewId is set, but it is now protected. 2024-08-06.11.05.12.mov |
@lovestart can you send us the demo app project where this is reproducible? |
I am using max kotlin demo, without changing anything. Clicking Templates API works fine, but Manual API and Manual Late Binding API do not display correctly. |
bro, just read the freaking source code(MaxNativeAdView's a() method), it's not about the demo, why you always stick on the demo project @NanaAmoah |
@lovestart or @linversion - what is your Ad Unit ID that you're having issues with? |
MAX SDK Version
12.5.0
Device/Platform Info
all device
Current Behavior
I'm trying to show my custom native ad template. But the icon will not show. Because in MaxNativeAdView's a() method, there's a logic assert this.h(which is the iconContentViewId cast to FrameLayout) not null, only if this.h != null will go in the setImageDrawable logic to this.g(the Icon ImageView) and the only way to set this
iconContentViewId is MaxNativeAdViewBinder's setIconContentViewId which is protected
Expected Behavior
can show icon image view without setting iconContentViewId or provide a method to set it
How to Reproduce
val binder = MaxNativeAdViewBinder.Builder(R.layout.applovin_native_banner)
.setTitleTextViewId(R.id.title_text_view)
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_textView)
.setIconImageViewId(R.id.icon_image_view)
.setOptionsContentViewGroupId(R.id.ad_options_view)
.setCallToActionButtonId(R.id.cta_button)
.build()
val adView = MaxNativeAdView(binder, activity)
Additional Info
No response
The text was updated successfully, but these errors were encountered: