Skip to content
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

Cannot show multiple native ads on android with NativeAdFactory (ios works fine) #1076

Closed
shijianan201 opened this issue May 7, 2024 · 13 comments
Labels
native ad Issues related to Native Ad platform-android Android applications specifically

Comments

@shijianan201
Copy link

shijianan201 commented May 7, 2024


Plugin Version

ad sdk version:5.0.0,flutter sdk version:3.19.1

I want to display two nativeads on same page,but finally only one ad shows, the second ad throws exception

The Android view returned from PlatformView#getView() was already added to a parent view.

Steps to Reproduce

  1. Follow all step in admob quick start,app open ad and rewardad works fine.
  2. My code likes below

Factory code

package com.construct.alice.multiple.flutter.plugin

import android.app.Activity
import android.view.LayoutInflater
import android.widget.ImageView
import androidx.core.view.isVisible
import com.construct.alice.databinding.ViewWonderlandNativeAdBinding
import com.google.android.gms.ads.nativead.NativeAd
import com.google.android.gms.ads.nativead.NativeAdView
import io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.NativeAdFactory

class WonderlandNativeAdFactory(val activity: Activity) : NativeAdFactory {

    private val vb: ViewWonderlandNativeAdBinding = ViewWonderlandNativeAdBinding.inflate(LayoutInflater.from(activity))

    override fun createNativeAd(nativeAd: NativeAd, customOptions: MutableMap<String, Any>?): NativeAdView {
        vb.adMedia.apply {
            mediaContent = nativeAd.mediaContent
        }
        vb.root.mediaView = vb.adMedia
        vb.root.headlineView = vb.adHeadline
        vb.root.callToActionView = vb.adCallToAction
        vb.root.iconView = vb.adAppIcon
        vb.root.advertiserView = vb.adAdvertiser
        if (nativeAd.headline == null) {
            vb.adHeadline.isVisible = false
        } else {
            vb.adHeadline.text = nativeAd.headline
            vb.adHeadline.isVisible = true
        }
        if (nativeAd.icon == null) {
            vb.adAppIcon.isVisible = false
        } else {
            vb.adAppIcon.isVisible = true
            vb.adAppIcon.setImageDrawable(nativeAd.icon!!.drawable)
        }
        if (nativeAd.callToAction == null) {
            vb.adCallToAction.isVisible = false
        } else {
            vb.adCallToAction.isVisible = true
            vb.adCallToAction.text = nativeAd.callToAction
        }
        vb.root.setNativeAd(nativeAd)
        return vb.root
    }
}

layout code

<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:minHeight="50dp"
        android:orientation="vertical">

        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="AD"
                android:textColor="#FF9FA6CC"
                android:textSize="10sp" />

            <View
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_weight="1" />

            <TextView
                android:id="@+id/ad_advertiser"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#FF9FA6CC"
                android:textSize="10sp" />

        </androidx.appcompat.widget.LinearLayoutCompat>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_r4_top">

            <com.google.android.gms.ads.nativead.MediaView
                android:id="@+id/ad_media"
                android:layout_width="match_parent"
                android:layout_height="172dp" />
        </FrameLayout>

        <androidx.appcompat.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_r4_bottom"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:paddingHorizontal="4dp"
                android:paddingVertical="8dp">

                <ImageView
                    android:id="@+id/ad_app_icon"
                    android:layout_width="18dp"
                    android:layout_height="18dp"
                    android:adjustViewBounds="true" />

                <TextView
                    android:id="@+id/ad_headline"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="4dp"
                    android:ellipsize="end"
                    android:lines="1"
                    android:textColor="#FFFFFFFF"
                    android:textSize="15sp"
                    android:textStyle="bold" />
            </LinearLayout>

            <TextView
                android:id="@+id/ad_call_to_action"
                android:layout_width="match_parent"
                android:layout_height="27.5dp"
                android:layout_marginHorizontal="5dp"
                android:layout_marginTop="4dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/btn_ad_open"
                android:gravity="center"
                android:textColor="#FF2C75DD"
                android:textSize="14sp" />
        </androidx.appcompat.widget.LinearLayoutCompat>

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

Flutter Activity code

abstract class BaseFlutterActivity : FlutterActivity() {
  
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        flutterEngine.plugins.add(GoogleMobileAdsPlugin())
        super.configureFlutterEngine(flutterEngine)
        GoogleMobileAdsPlugin.registerNativeAdFactory(
            flutterEngine,
            WonderlandNativeAdFactory::class.java.simpleName,
            WonderlandNativeAdFactory(this)
        )
    }

    override fun cleanUpFlutterEngine(flutterEngine: FlutterEngine) {
        super.cleanUpFlutterEngine(flutterEngine)
        GoogleMobileAdsPlugin.unregisterNativeAdFactory(flutterEngine,WonderlandNativeAdFactory::class.java.simpleName)
    }

    override fun provideFlutterEngine(context: Context): FlutterEngine? {
        return bindings.engine
    }


}

flutter code

class AdCardView extends StatefulWidget {
  const AdCardView({super.key});


  @override
  State<StatefulWidget> createState() {
    return _AdCardViewState();
  }
}

class _AdCardViewState extends State<AdCardView> with AutomaticKeepAliveClientMixin {

  NativeAd? _ad;
  bool adLoaded = false;

  @override
  void initState() {
    super.initState();
    loadNewAd();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return LayoutBuilder(builder: (ctx, cons) {
      if (_ad != null && adLoaded) {
        return Container(
          width: cons.maxWidth,
          height: 270,
          alignment: Alignment.center,
          child: AdWidget(
            ad: _ad!,
          ),
        );
      } else {
        return Container(
          color: Colors.green,
          width: cons.maxWidth,
          height: 270.w,
        );
      }
    });

  }

  void loadNewAd() async {
    _ad = await loadNativeAdPurely();
    setState(() {
      adLoaded = _ad != null;
    });
  }

Future<NativeAd?> loadNativeAdPurely() async {
    Completer<Ad?> completer = Completer();
    var nativeAd = NativeAd(
        adUnitId: "ca-app-pub-3940256099942544/2247696110",
        factoryId: "WonderlandNativeAdFactory",
        listener: NativeAdListener(
          onAdLoaded: (ad) {
            completer.complete(ad);
          },
          onAdFailedToLoad: (ad, error) {
            ad.dispose();
            completer.complete(null);
          },
          // Called when a click is recorded for a NativeAd.
          onAdClicked: (ad) {},
          // Called when an impression occurs on the ad.
          onAdImpression: (ad) {},
          // Called when an ad removes an overlay that covers the screen.
          onAdClosed: (ad) {},
          // Called when an ad opens an overlay that covers the screen.
          onAdOpened: (ad) {},
          // For iOS only. Called before dismissing a full screen view
          onAdWillDismissScreen: (ad) {},
          // Called when an ad receives revenue value.
          onPaidEvent: (ad, valueMicros, precision, currencyCode) {},
        ),
        request: AdRequest());
    await nativeAd.load();
    var ad = await completer.future;
    if (ad != null) {
      return nativeAd;
    } else {
      return null;
    }
  }

  @override
  void setState(VoidCallback fn) {
    if(mounted) {
      super.setState(fn);
    }
  }

  @override
  void dispose() {
    _ad?.dispose();
    super.dispose();
  }

  @override
  bool get wantKeepAlive => true;
}

page code

class TestNativeAdPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TestNativeAdPageState();
  }
}

class _TestNativeAdPageState extends State<TestNativeAdPage> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Column(
        children: [
          AdCardView(),
          SizedBox(height: 10,),
          AdCardView()
        ],
      ),
    );
  }
}

  1. Route to TestNativeAdPage

Expected results:two native ad show normally in screen

Actual results:only one ad show,the other throw exception

Logs
I/flutter (27759): PlatformException(error, java.lang.IllegalStateException: The Android view returned from PlatformView#getView() was already added to a parent view.
I/flutter (27759): 	at io.flutter.plugin.platform.PlatformViewsController$1.createForTextureLayer(PlatformViewsController.java:203)
I/flutter (27759): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:128)
I/flutter (27759): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:55)
I/flutter (27759): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
I/flutter (27759): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
I/flutter (27759): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
I/flutter (27759): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
I/flutter (27759): 	at android.os.Handler.handleCallback(Handler.java:938)
I/flutter (27759): 	at android.os.Handler.dispatchMessage(
I/flutter (27759): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
I/flutter (27759): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
I/flutter (27759): <asynchronous suspension>
I/flutter (27759): #2      SurfaceAndroidViewController._sendCreateMessage (package:flutter/src/services/platform_views.dart:1051:30)
I/flutter (27759): <asynchronous suspension>
I/flutter (27759): #3      AndroidViewController.create (package:flutter/src/services/platform_views.dart:838:5)
I/flutter (27759): <asynchronous suspension>
I/flutter (27759): ----------------------------------------------------
[✓] Flutter (Channel stable, 3.19.1, on macOS 13.3.1 22E772610a darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.19.1 on channel stable at /Users/shijianan/Library/flutter_kszt
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision abb292a07e (3 months ago), 2024-02-20 14:35:05 -0800
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/shijianan/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/shijianan/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Community Edition (version 2022.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.86.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is localhost,127.0.0.1
    • NO_PROXY contains localhost
    • NO_PROXY contains 127.0.0.1
    ! NO_PROXY does not contain ::1

[✓] Connected device (3 available)
    • SM N975U (mobile) • RF8M81ZE6EB • android-arm64  • Android 11 (API 30)
    • macOS (desktop)   • macos       • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 124.0.6367.119

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@malandr2 malandr2 added the in triage Issue currently being evaluated label May 8, 2024
@malandr2
Copy link
Collaborator

malandr2 commented May 9, 2024

Hey @shijianan201, the code you provided has app-specififc language that I cannot infer. Can you please provide a minimum reproducible sample so I can try to replicate this?

Thanks!

@malandr2 malandr2 added the feedback required Further information is requested label May 9, 2024
@shijianan201
Copy link
Author

shijianan201 commented May 10, 2024

Hey @shijianan201, the code you provided has app-specififc language that I cannot infer. Can you please provide a minimum reproducible sample so I can try to replicate this?

Thanks!

Hey @malandr2 I updated my code above, and I found a new issue yesterday, when I use code above,native ad can show only once.It occurs when I placed only one AdCardView in TestNativeAdPage's build function,first time I enter TestNativeAdPage it works fine, but the next time I entered it will show nothing and no Exception throws.The console print like below:

I/flutter (27263): [D]  native ad load success pool size = 0,mediationAdapterClassName = com.google.ads.mediation.admob.AdMobAdapter 332317506(this log indicat onAdLoaded function is called)
I/flutter (27263): [D]  native ad load complete pool size = 0,332317506
I/PlatformViewsController(27263): Hosting view in view hierarchy for platform view: 1
I/PlatformViewsController(27263): PlatformView is using SurfaceTexture backend

probably because I use filament to show 3d model in my app(I use another platform view to connect filament to show 3d model)?

@github-actions github-actions bot removed the feedback required Further information is requested label May 10, 2024
@malandr2
Copy link
Collaborator

@shijianan201 thanks for following up. It's possible although I'm not familiar with filament (we don't support it in our samples) but if you're able to still reproduce the issue without filament let us know and we can begin the debugging process.

@malandr2 malandr2 added platform-android Android applications specifically and removed in triage Issue currently being evaluated labels May 10, 2024
@malandr2 malandr2 changed the title Cannot show multiple nativead on android platform(ios works fine) Cannot show multiple native ads on android with Filament (ios works fine) May 10, 2024
@shijianan201
Copy link
Author

shijianan201 commented May 11, 2024

@shijianan201 thanks for following up. It's possible although I'm not familiar with filament (we don't support it in our samples) but if you're able to still reproduce the issue without filament let us know and we can begin the debugging process.

@malandr2 thank you for taking the time, I made a ad test project use pure code without filament, but same as before, ad didn't display when I route to ad page twice. Could you please review my code and figure out why? I also record a video below

20240511-144741.mp4

@malandr2 malandr2 added the native ad Issues related to Native Ad label May 14, 2024
@malandr2
Copy link
Collaborator

Hi @shijianan201, I'm getting a crash on launch for iOS with error
[ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm(42)] Using the Impeller rendering backend.

For reference, we don't support Impeller at this time.

For Android it looks like you're only loading one native ad (which loads successfully) for one card view. You can confirm this by using ad inspector.

Can you update your sample to replicate your issue on Android and resolve the iOS crash so I can take another look.

Thanks!

@malandr2 malandr2 added the feedback required Further information is requested label May 15, 2024
@shijianan201
Copy link
Author

shijianan201 commented May 16, 2024

Hi @shijianan201, I'm getting a crash on launch for iOS with error [ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm(42)] Using the Impeller rendering backend.

For reference, we don't support Impeller at this time.

For Android it looks like you're only loading one native ad (which loads successfully) for one card view. You can confirm this by using ad inspector.

Can you update your sample to replicate your issue on Android and resolve the iOS crash so I can take another look.

Thanks!

Hello @malandr2 I disabled impeller on both android and ios in ad test project, and print log in onAdLoaded like below

d809eaab-e15d-45d0-80a3-d165d7db922b

Every time I enter to ad page this log will print with different response id, but same as before,ad only show only once, but I hope to use one native ad unit id gobal to show multiple ads in ListView,how can I do this? My console prints:

Launching lib/main.dart on SM N975U in debug mode...
Running Gradle task 'assembleDebug'...
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk...
W/FlutterEngineCxnRegstry( 2418): Attempted to register plugin (io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin@3264464) but it was already registered with this FlutterEngine (io.flutter.embedding.engine.FlutterEngine@979c6cd).
Debug service listening on ws://127.0.0.1:63321/t44GWGOD3dA=/ws
Syncing files to device SM N975U...
D/DynamitePackage( 2418): Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
I/Ads     ( 2418): Updating ad debug logging enablement.
I/WebViewFactory( 2418): Loading com.google.android.webview version 124.0.6367.123 (code 636712333)
W/linker  ( 2418): Warning: "/data/app/~~mXUwZFYrj24-Pldb2IekAw==/com.google.android.trichromelibrary_636712333-KHGf4vlRE3ltHsibVbfjSQ==/base.apk!/lib/arm64-v8a/libmonochrome_64.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring)
I/cr_WVCFactoryProvider( 2418): Loaded version=124.0.6367.123 minSdkVersion=29 isBundle=true multiprocess=true packageId=2
I/chromium( 2418): [0516/104839.726701:INFO:variations_seed_loader.cc(66)] Failed to open file for reading.: No such file or directory (2)
I/cr_LibraryLoader( 2418): Successfully loaded native library
I/cr_CachingUmaRecorder( 2418): Flushed 5 samples from 5 histograms, 0 samples were dropped.
I/cr_CombinedPProvider( 2418): #registerProvider() provider:WV.V7@6476308 isPolicyCacheEnabled:false policyProvidersSize:0
I/cr_PolicyProvider( 2418): #setManagerAndSource() 0
I/cr_CombinedPProvider( 2418): #linkNativeInternal() 1
I/cr_AppResProvider( 2418): #getApplicationRestrictionsFromUserManager() Bundle[EMPTY_PARCEL]
I/cr_PolicyProvider( 2418): #notifySettingsAvailable() 0
I/cr_CombinedPProvider( 2418): #onSettingsAvailable() 0
I/cr_CombinedPProvider( 2418): #flushPolicies()
W/Ads     ( 2418): Update ad debug logging enablement as false
W/AudioCapabilities( 2418): Unsupported mime audio/x-ape
W/AudioCapabilities( 2418): Unsupported mime audio/evrc
W/AudioCapabilities( 2418): Unsupported mime audio/evrc
W/AudioCapabilities( 2418): Unsupported mime audio/x-ima
W/VideoCapabilities( 2418): Unsupported mime video/mp43
W/AudioCapabilities( 2418): Unsupported mime audio/qcelp
W/AudioCapabilities( 2418): Unsupported mime audio/qcelp
W/VideoCapabilities( 2418): Unsupported mime video/wvc1
W/VideoCapabilities( 2418): Unsupported mime video/x-ms-wmv
W/AudioCapabilities( 2418): Unsupported mime audio/x-ms-wma
W/VideoCapabilities( 2418): Unsupported mime video/x-ms-wmv7
W/VideoCapabilities( 2418): Unsupported mime video/x-ms-wmv8
W/AudioCapabilities( 2418): Unsupported mime audio/x-ima
W/AudioCapabilities( 2418): Unsupported mime audio/x-ape
W/AudioCapabilities( 2418): Unsupported mime audio/evrc
W/AudioCapabilities( 2418): Unsupported mime audio/mpeg-L1
W/AudioCapabilities( 2418): Unsupported mime audio/mpeg-L2
W/AudioCapabilities( 2418): Unsupported mime audio/qcelp
W/AudioCapabilities( 2418): Unsupported mime audio/evrc
W/AudioCapabilities( 2418): Unsupported mime audio/qcelp
W/VideoCapabilities( 2418): Unsupported mime video/wvc1
W/VideoCapabilities( 2418): Unrecognized profile/level 1/32 for video/mp4v-es
W/VideoCapabilities( 2418): Unrecognized profile/level 32768/2 for video/mp4v-es
W/VideoCapabilities( 2418): Unrecognized profile/level 32768/64 for video/mp4v-es
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 65536 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 1 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 2 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 524288 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 8 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 65536 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 1 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 2 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 524288 of codec video/avc
W/cr_VAUtil( 2418): Unknown level: 131072 for profile 8 of codec video/avc
I/Ads     ( 2418): JS: The jsLoaded GMSG has been sent (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html:804)
I/chromium( 2418): [INFO:CONSOLE(804)] "The jsLoaded GMSG has been sent", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (804)
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389849040]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389849040]
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x105a263 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655390111280]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655390111280]
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655390111632]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655390111632]
I/ViewRootImpl@97b167e[MainActivity]( 2418): Relayout returned: old=(0,0,1440,3040) new=(0,0,1440,3040) req=(1440,3040)0 dur=5 res=0x3 s={true -5476376651095000096} ch=false fn=1
I/ViewRootImpl@97b167e[MainActivity]( 2418): updateBoundsLayer: shouldReparent = false t = android.view.SurfaceControl$Transaction@f9f702b sc = Surface(name=Bounds for - com.construct.alice/com.construct.alice.flutter_ad_test.MainActivity@0)/@0x7520c88 frame = 1
I/SurfaceView( 2418): applySurfaceTransforms: t = android.view.SurfaceControl$Transaction@e1d0a46 surfaceControl = Surface(name=SurfaceView - com.construct.alice/com.construct.alice.flutter_ad_test.MainActivity@34c9892@0)/@0x3a2e407 frame = 1
I/ViewRootImpl@97b167e[MainActivity]( 2418): MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager( 2418): prepareNavigationBarInfo() DecorView@88ec2e7[MainActivity]
D/InputMethodManager( 2418): getNavigationBarColor() -855310
D/InputMethodManager( 2418): prepareNavigationBarInfo() DecorView@88ec2e7[MainActivity]
D/InputMethodManager( 2418): getNavigationBarColor() -855310
V/InputMethodManager( 2418): Starting input: tba=com.construct.alice ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager( 2418): startInputInner - Id : 0
I/InputMethodManager( 2418): startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport( 2418): Input channel constructed: 'ClientS', fd=240
D/InputMethodManager( 2418): prepareNavigationBarInfo() DecorView@88ec2e7[MainActivity]
D/InputMethodManager( 2418): getNavigationBarColor() -855310
V/InputMethodManager( 2418): Starting input: tba=com.construct.alice ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager( 2418): startInputInner - Id : 0
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389887056]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389887056]
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389849040]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389849040]
D/ProfileInstaller( 2418): Installing profile for com.construct.alice
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme pointer 0
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme pointer 1
D/DynamitePackage( 2418): Instantiating com.google.android.gms.ads.ChimeraAdLoaderBuilderCreatorImpl
I/Ads     ( 2418): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("AC6B75B66C142324AF7F8D288CC4D147")) to get test ads on this device.
W/Ads     ( 2418): Invoke Firebase method getInstance error.
W/Ads     ( 2418): The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firebase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
W/ConnectionStatusConfig( 2418): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.CACHE
W/ConnectionStatusConfig( 2418): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START
I/DynamiteModule( 2418): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:241199801
I/DynamiteModule( 2418): Selected remote version of com.google.android.gms.ads.dynamite, version >= 241199801
I/flutter ( 2418): ad load success CJzxg7GUkYYDFRtzDwIdhNUCyw
I/PlatformViewsController( 2418): Hosting view in view hierarchy for platform view: 0
I/PlatformViewsController( 2418): PlatformView is using SurfaceTexture backend
E/FrameEvents( 2418): updateAcquireFence: Did not find frame.
W/construct.alic( 2418): Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
D/InputTransport( 2418): Input channel constructed: '3c88a43', fd=262
I/ViewRootImpl@27de131[MainActivity]( 2418): setView = com.google.android.gms.ads.internal.webview.z@71c0016 TM=true
E/FrameEvents( 2418): updateAcquireFence: Did not find frame.
I/Ads     ( 2418): JS: The jsLoaded GMSG has been sent (https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html:804)
I/chromium( 2418): [INFO:CONSOLE(804)] "The jsLoaded GMSG has been sent", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/production/sdk-core-v40-impl.html (804)
E/FrameEvents( 2418): updateAcquireFence: Did not find frame.
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xf32cc33 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,0,1440,3040) new=(0,0,1120,0) req=(1120,0)4 dur=6 res=0x1 s={false 0} ch=false fn=-1
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xf32cc33 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,0,1120,0) new=(0,917,1120,1459) req=(1120,542)4 dur=3 res=0x1 s={false 0} ch=false fn=-1
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,917,1120,1459) new=(0,917,1120,1459) req=(1120,542)0 dur=6 res=0x7 s={true -5476376651094398416} ch=true fn=-1
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389542096]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389542096]
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,917,1120,1459) new=(0,917,1120,1459) req=(1120,542)0 dur=6 res=0x1 s={true -5476376651094398416} ch=false fn=2
I/ViewRootImpl@27de131[MainActivity]( 2418): MSG_RESIZED_REPORT: frame=(0,917,1120,1459) ci=(0,0,0,0) vi=(0,0,0,0) or=1
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389543328]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389543328]
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,917,1120,1459) new=(0,917,1120,1459) req=(1120,542)0 dur=5 res=0x1 s={true -5476376651094398416} ch=false fn=3
I/ViewRootImpl@27de131[MainActivity]( 2418): ViewPostIme pointer 0
W/construct.alic( 2418): Accessing hidden method Landroid/view/MotionEvent;->getEventTimeNano()J (greylist, reflection, allowed)
I/ViewRootImpl@27de131[MainActivity]( 2418): ViewPostIme pointer 1
I/SurfaceControl( 2418): nativeRelease nativeObject s[-5476376655389542096]
I/SurfaceControl( 2418): nativeRelease nativeObject e[-5476376655389542096]
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0xf32cc33 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1810 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/SurfaceControl( 2418): assignNativeObject: nativeObject = 0 Surface(name=null)/@0x54aabf0 / android.view.SurfaceControl.readFromParcel:1117 android.view.IWindowSession$Stub$Proxy.relayout:1820 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995 
I/ViewRootImpl@27de131[MainActivity]( 2418): Relayout returned: old=(0,917,1120,1459) new=(0,917,1120,1459) req=(1120,542)8 dur=4 res=0x5 s={false 0} ch=true fn=21
W/Ads     ( 2418): #004 The webview is destroyed. Ignoring action.
I/ViewRootImpl@27de131[MainActivity]( 2418): dispatchDetachedFromWindow
D/InputTransport( 2418): Input channel destroyed: '3c88a43', fd=262
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme key 0
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme key 1
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme pointer 0
I/ViewRootImpl@97b167e[MainActivity]( 2418): ViewPostIme pointer 1
D/DynamitePackage( 2418): Instantiating com.google.android.gms.ads.ChimeraAdLoaderBuilderCreatorImpl
I/Ads     ( 2418): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("AC6B75B66C142324AF7F8D288CC4D147")) to get test ads on this device.
W/ConnectionStatusConfig( 2418): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START
I/DynamiteModule( 2418): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:241199801
I/DynamiteModule( 2418): Selected remote version of com.google.android.gms.ads.dynamite, version >= 241199801
I/System.out( 2418): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out( 2418): (HTTPLog)-Static: isSBSettingEnabled false
I/flutter ( 2418): ad load success HXRFZrTAFvy-vcAP6r-TgAU
I/PlatformViewsController( 2418): Hosting view in view hierarchy for platform view: 1
I/PlatformViewsController( 2418): PlatformView is using SurfaceTexture backend
E/FrameEvents( 2418): updateAcquireFence: Did not find frame.
E/FrameEvents( 2418): updateAcquireFence: Did not find frame.

@github-actions github-actions bot removed the feedback required Further information is requested label May 16, 2024
@shijianan201
Copy link
Author

Hi @shijianan201, I'm getting a crash on launch for iOS with error [ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm(42)] Using the Impeller rendering backend.

For reference, we don't support Impeller at this time.

For Android it looks like you're only loading one native ad (which loads successfully) for one card view. You can confirm this by using ad inspector.

Can you update your sample to replicate your issue on Android and resolve the iOS crash so I can take another look.

Thanks!

@malandr2 Any feedback? I find It works fine when I remove factory id. code likes below.

fa5d712e-9997-4f02-bf6e-a613f4c769e0

This issue only occurs when I want to custom ad style by using NativeAdFactory.

@shijianan201 shijianan201 changed the title Cannot show multiple native ads on android with Filament (ios works fine) Cannot show multiple native ads on android with NativeAdFactory (ios works fine) May 24, 2024
@woxxin20
Copy link

i used you code as experiment into my project , and it's completely work for me , but it's take 2-3 second to load after come in the screen, it's very annoying thing as user interfere, and also more if internet is normally work then it's took 4-5 second to load native ads. how i load with screen load, so ads take place , we can do that ?? like pre-load a native ads in every called before for multiple time show ads 🤔

@shijianan201
Copy link
Author

i used you code as experiment into my project , and it's completely work for me , but it's take 2-3 second to load after come in the screen, it's very annoying thing as user interfere, and also more if internet is normally work then it's took 4-5 second to load native ads. how i load with screen load, so ads take place , we can do that ?? like pre-load a native ads in every called before for multiple time show ads 🤔

Really?Could you record a video and comment again? I can not see more than one native ad on my phone when I use NativeAdFactory to custom ad style.

@shijianan201
Copy link
Author

shijianan201 commented May 28, 2024

Finally I move viewbinding new instance in createNativeAd function , it works fine.

@woxxin20
Copy link

woxxin20 commented May 29, 2024

i used you code as experiment into my project , and it's completely work for me , but it's take 2-3 second to load after come in the screen, it's very annoying thing as user interfere, and also more if internet is normally work then it's took 4-5 second to load native ads. how i load with screen load, so ads take place , we can do that ?? like pre-load a native ads in every called before for multiple time show ads 🤔

Really?Could you record a video and comment again? I can not see more than one native ad on my phone when I use NativeAdFactory to custom ad style.

Recorder_29052024_102759.online-video-cutter.com.mp4

yeah ,certainly m i attached the video,

you can see that ,

it's can to much to load, i used your code.
HOW i reduce the time of loading , can we do like any pre-load ads or?

please if you have any content about that provide.

@shijianan201
Copy link
Author

shijianan201 commented May 29, 2024

i used you code as experiment into my project , and it's completely work for me , but it's take 2-3 second to load after come in the screen, it's very annoying thing as user interfere, and also more if internet is normally work then it's took 4-5 second to load native ads. how i load with screen load, so ads take place , we can do that ?? like pre-load a native ads in every called before for multiple time show ads 🤔

Really?Could you record a video and comment again? I can not see more than one native ad on my phone when I use NativeAdFactory to custom ad style.

Recorder_29052024_102759.online-video-cutter.com.mp4
yeah ,certainly m i attached the video,

you can see that ,

it's can to much to load, i used your code. HOW i reduce the time of loading , can we do like any pre-load ads or?

please if you have any content about that provide.

If you want to display native ad in ListView, I don't recommend to pre load because It makes lifecycle control difficult, and you may receive crash, otherwise your can cache ads from main function.

@woxxin20
Copy link

woxxin20 commented May 30, 2024

Thanks For responding me, it's glad to me,

No bro, it's not a ListView , you can see in video it's complete multiple screens, that are navigate one to another screen just . and my problem is it's take a time to load/display

Have we go ,

DEMO AD:-

https://github.com/woxxin20/admob_load.git

i create one demo project , please you can check code,
If possible give the solution of loading time and reduce displaying delay.

like with nagivate to another screen native ads should be present in screen without any delayed or load as soon as fast ad display ,

please check OUT and Review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
native ad Issues related to Native Ad platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests

3 participants