我在 flutter 原生广告 (android) 上遇到此错误:
\nPlatformException(NativeAdError, Can't find NativeAdFactory with id: homeScreen, null, null)
google_mobile_ads: ^0.13.0\n
Run Code Online (Sandbox Code Playgroud)\n这是我的 HomeScreenNativeAd.kt 文件
\nclass HomeScreenNativeAd(val context: Context) : GoogleMobileAdsPlugin.NativeAdFactory {\n\n override fun createNativeAd(\n nativeAd: NativeAd,\n customOptions: MutableMap<String, Any>?\n ): NativeAdView {\n val homeScreenNativeView = LayoutInflater.from(context)\n .inflate(R.layout.home_screen_native_ad, null) as NativeAdView\n\n with(homeScreenNativeView) {\n val attributionViewSmall =\n findViewById<TextView>(R.id.tv_home_item_native_ad_attribution_small)\n\n\n val icon = findViewById<ImageView>(R.id.home_item_bg_image)\n\n\n val image = nativeAd.icon\n if (image != null) {\n attributionViewSmall.visibility = View.VISIBLE\n icon.setImageDrawable(image.drawable)\n } else {\n attributionViewSmall.visibility = View.INVISIBLE\n }\n this.iconView …
Run Code Online (Sandbox Code Playgroud)