AppLovin / AppLovin-MAX-SDK-Android

Other
210 stars 95 forks source link

Native in Custom Adapter #666

Closed wxmylife closed 1 month ago

wxmylife commented 1 month ago

MAX SDK Version

12.4.3

Device/Platform Info

Android

Current Behavior

Hi, The log display 'does not support native ads' when I am using the custom adapter load native ad with Applovin SDK 12.4.3.

I don't know the reason for this problem, why it indicates 'does not support native ads' and the error message is 'Invalid Configuration'. Also, sometimes 'listener.onNativeAdLoaded(maxNativeAd, null)' has been executed, but the 'native ad' does not trigger 'onNativeAdLoaded'.

[MediationAdapterWrapper] ApplovinAdapter: running initialize...
[MediationAdapterWrapper] Initializing ApplovinAdapter on thread: Thread[AppLovinSdk:shared_thread_pool,1,main] with 'run_on_ui_thread' value: false
[MediationAdapterWrapper] ApplovinAdapter: finished initialize
[MediationAdapterWrapper] ApplovinAdapter: running load_ad...
[MediationAdapterWrapper] Setting timeout 10000ms for MediatedAd{thirdPartyAdPlacementId=/22934534814/stream/1Qbtctg518_0.10, adUnitId=de94d21c7dd7dd4, format=NATIVE, networkName='MediationAdapter'}
[ApplovinAdapter] This adapter (1.0.3) does not support native ads.
[MediationAdapterWrapper] ApplovinAdapter: native ad ad failed to load with error: MaxError{code=-5202, message="Invalid Configuration", mediatedNetworkErrorCode=0, mediatedNetworkErrorMessage=""}
[MediationService] Destroying MediatedAd{thirdPartyAdPlacementId=/22934534814/stream/1Qbtctg518_0.10, adUnitId=de94d21c7dd7dd4, format=NATIVE, networkName='MediationAdapter'}
[MediationAdapterWrapper] ApplovinAdapter: running destroy...
[MediationAdapterWrapper] Marking ApplovinAdapter as disabled due to: destroy

Expected Behavior

No response

How to Reproduce

use the custom adapter load native ad

Additional Info

No response

thomasmso commented 1 month ago

@wxmylife - that is due to your adapter not overriding the following method from com.applovin.mediation.adapters.MediationAdapterBase:

@Override
public void loadNativeAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxNativeAdAdapterListener listener)
   ...
}
wxmylife commented 1 month ago

@thomasmso I apologize for not being clear earlier. In fact, I have rewritten the com.applovin.mediation.adapters.MediationAdapterBase.loadNativeAd method, and I indeed called the onNativeAdLoaded method through MaxNativeAdAdapterListener. Below are the code and logs: code:

@Override
public void loadNativeAd(MaxAdapterResponseParameters parameters, Activity activity, MaxNativeAdAdapterListener listener) {
     // load ad
     Utils.log("Return Ad To Applovin");
     listener.onNativeAdLoaded(maxNativeAd, extraInfo);
}

log:

[Applovin] Native Ad onAdLoaded: /22964834814/tap4fun/1Qbtctg518_0.10
[Applovin] Return Ad To Applovin
[MediationAdapterWrapper] ApplovinAdapter: native ad loaded with extra info: Bundle[{creative_id=Hb0-ZueTM4uV29gPqsuU-A0}]
[MaxNativeAdLoader] MaxNativeAdLoader(adUnitId=de94d5e6c7dd7dd4, sdk=AppLovinSdk{sdkKey='-OJaaG-tPBWONJcxlKSu02C6ehkbloUkApIl4HcUS7tqRUmApC2qFFwvxeVgQ-ObohLszyKQ4BFVf_gTCkHS-C', isInitialized=true, isFirstSession=false})
[MaxNativeAdLoader] Created new MaxNativeAdLoader (MaxNativeAdLoader{adUnitId='de94d5e6c7dd7dd4', nativeAdListener=null, revenueListener=null})
[MaxNativeAdLoader] setNativeAdListener(listener=com.gamebridge.enjoy4fun.ads.AdManager$NativeListener@1cf9280)
[MaxNativeAdLoader] Setting native ad listener: com.gamebridge.enjoy4fun.ads.AdManager$NativeListener@1cf9280
[MaxNativeAdLoader] loadAd(adView=null)
[MaxNativeAdLoader] Loading native ad for 'de94d5e6c7dd7dd4' into 'null' and notifying com.applovin.impl.mediation.ads.MaxNativeAdLoaderImpl$c@413e4e5...
[MediationAdapterManager] Not attempting to load LINKEDIN_DSP due to prior errors
[MediationAdapterManager] Not attempting to load DV360_BIDDING due to prior errors
[TaskCollectSignals] Collected signal from SignalProviderSpec{adObject={"name":"LINKEDIN_DSP","server_parameters":{"sdk_key":"15550566edbcae560bac1ccdaa33392eeb80cd9b1d4797a52fdccfc3ea114d15"},"class":"com.applovin.dsp.adapters.LinkedInDspAdapter","adapter_timeout_ms":1000,"max_signal_length":32768,"scode":"2!v3!190741.1715387668917!AWtQdBc6etjNNtE9_YpXZAJkIJGLtRiDC2oXrzW3yTE*","run_on_ui_thread":false}}
[TaskCollectSignals] Collected signal from SignalProviderSpec{adObject={"name":"DV360_BIDDING","server_parameters":{"bidder":"dv360"},"class":"com.applovin.mediation.adapters.GoogleMediationAdapter","adapter_timeout_ms":1000,"max_signal_length":32768,"scode":"2!v3!190741.1715387668917!KN9QrfenDGXShevANH7xUg7vAOzakyZa6ua9cfq7gEw*","run_on_ui_thread":false,"use_cached_adapter":false}}
[TaskFetchMediatedAd] Fetching next ad for NATIVE ad unit de94d5e6c7dd7dd4
[ConnectionManager] Sending POST request to id=#2079035339 "https://ms4.applovin.com/1.0/mediate?p=2%3A8a2387b7dbed018e5e485792eac2b56833ce8a3a%3AApIl4HcUS7tqRUmApC2qFFwvxeVgQ-ObohLszyKQ4BFVf_gTCkHS-C%3AKAAAAAAAAABI9f6LZ7_f0w**xyGQB4Q7z9XjFupfHSAZd3IigGvLzyfBHHuN0jqX2oQwuWXAVtaLhhhArGXTvcWufumxXjMCJORPjg**"...
[TaskCollectSignals] MEDIATION queue finished task TaskCollectSignals
[ConnectionManager] Successful POST returned 200 in 0.34 s over wifi to #2079035339 "ms4.applovin.com/1.0/mediate"
[TaskProcessMediationWaterfall] Starting waterfall for NATIVE ad unit de94d5e6c7dd7dd4 with 1 ad(s)...
[TaskProcessMediationWaterfall] Loading ad 1 of 1 from CUSTOM_NETWORK_SDK for NATIVE ad unit de94d5e6c7dd7dd4
[MediationService] Loading MediatedAd{thirdPartyAdPlacementId=/22964834814/tap4fun/1Qbtctg518_0.10, adUnitId=de94d5e6c7dd7dd4, format=NATIVE, networkName='BeesMediationAdapter'}...
[MediationAdapterManager] Loaded CUSTOM_NETWORK_SDK
[MediationAdapterManager] Loaded CUSTOM_NETWORK_SDK
[MediationAdapterInitializationManager] Initializing adapter MediatedAd{thirdPartyAdPlacementId=/22964834814/tap4fun/1Qbtctg518_0.10, adUnitId=de94d5e6c7dd7dd4, format=NATIVE, networkName='BeesMediationAdapter'}
[MediationAdapterWrapper] ApplovinAdapter: running initialize...
[MediationAdapterWrapper] Initializing ApplovinAdapter on thread: Thread[AppLovinSdk:shared_thread_pool,1,main] with 'run_on_ui_thread' value: false
[MediationAdapterWrapper] ApplovinAdapter: finished initialize
[MediationAdapterWrapper] ApplovinAdapter: running load_ad...
[MediationAdapterWrapper] Setting timeout 10000ms for MediatedAd{thirdPartyAdPlacementId=/22964834814/tap4fun/1Qbtctg518_0.10, adUnitId=de94d5e6c7dd7dd4, format=NATIVE, networkName='BeesMediationAdapter'}
[ApplovinAdapter] This adapter (1.0.3) does not support native ads.
[MediationAdapterWrapper] ApplovinAdapter: native ad ad failed to load with error: MaxError{code=-5202, message="Invalid Configuration", mediatedNetworkErrorCode=0, mediatedNetworkErrorMessage=""}
[MediationAdapterWrapper] ApplovinAdapter: finished load_ad
thomasmso commented 1 month ago

As long as you implemented the MaxNativeAdAdapter interface, and override the method above without calling super.loadNativeAd(...) it should work. That is the most I can assist with as our support is limited for custom adapter integrations.

wxmylife commented 1 month ago

After I stopped calling super.loadNativeAd(...), everything worked normally and it no longer shows the log does not support native ads. Thank you, and have a nice day.