Closed xz013 closed 3 years ago
Hi @xz013 , When you're awaiting in the main(), you should make sure the binding is initialized. Otherwise the plugin may not behave as it should. Adding WidgetsFlutterBinding.ensureInitialized() line in the main() will solve the problem. Also make sure it's the first line in the main().
Future<void> initHwAds() async {
try {
await HwAds.init();
} catch (e) {
print('EXCEPTION | $e');
}
}
void main() {
WidgetsFlutterBinding.ensureInitialized();
initHwAds();
runApp(MyApp());
}
thank you for answer , app run but no ads :
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Waiting for Android SDK built for x86 to report its views...
Debug service listening on ws://127.0.0.1:59414/SaX5GPTbwyc=/ws
Syncing files to device Android SDK built for x86...
I/HiAd (20925):
I/HiAd (20925): ============================================================================
I/HiAd (20925): ====== HiAd-13.4.32.300
I/HiAd (20925): ====== Brand: google Model: Android SDK built for x86 Release: 8.1.0 API: 27
I/HiAd (20925): ============================================================================
I/HUAWEI_ADS_PLUGIN(20925): HW Ads Kit initialized
I/zygote (20925): Rejecting re-init on previously-failed class java.lang.Class
You can't see the ad because your device brand is not Huawei. For details, please refer here.
But you can test your app in AppGallery Connect with Cloud Debugging.
Here are the steps to test your app on the cloud:
You can check here if the ads are being displayed as they should.
really big thank you for helping me , but i got this new error :
App installation failed. Error code: com.android.ddmlib.InstallException: INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113
i don't know how i can fix it https://prnt.sc/vmbfeh
All works thank you very much
Hello , I have some problem and hope you can help me :
1- EXCEPTION | ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. I/flutter (20409): If you're running an application and need to access the binary messenger before
runApp()
has been called (for example, during plugin initialization), then you need to explicitly call theWidgetsFlutterBinding.ensureInitialized()
first. I/flutter (20409): If you're running a test, you can call theTestWidgetsFlutterBinding.ensureInitialized()
as the first line in your test'smain()
method to initialize the binding.https://prnt.sc/vl6kxg
2- Unhandled Exception: NoSuchMethodError: The getter 'channel' was called on null.
https://prnt.sc/vl6l6e
3-MissingPluginException(No implementation found for method listen on channel com.huawei.hms.flutter.ads/banner/event/452747774)
https://prnt.sc/vl6li1
4-_testAdSlotId = "testw6vs28auh3"; from where i can register my app ads and get my ads banner id !
hope you can give me a link
My code :
-main
Future initHwAds() async {
try {
await HwAds.init();
} catch (e) {
print('EXCEPTION | $e');
}
}
void main() {
initHwAds();
runApp(MyApp()); }
-HomePage
//ads BannerAd _bannerAd; InterstitialAd _interstitialAd; CustomeAdmob myCustomeadmob = CustomeAdmob();
@override void initState() {
}
@override void dispose() { super.dispose(); //ads
}
-CustomeAdmob [Class]
static final String _testAdSlotId = "testw6vs28auh3"; final AdParam _adParam = AdParam(); BannerAdSize bannerAdSize = BannerAdSize.s320x50;
BannerAd createBannerAd() { return BannerAd( adSlotId: _testAdSlotId, size: bannerAdSize, adParam: _adParam, bannerRefreshTime: 5000, listener: (AdEvent event, {int errorCode}) { print("Banner Ad event : $event"); }, ); }
InterstitialAd createInterstitialAd(){ return InterstitialAd( adSlotId: "teste9ih9j0rc3", adParam: AdParam(), ); }
void testBannerAdSizeMethods() async { print('isFullWidthSize : ${bannerAdSize.isFullWidthSize}'); print('isDynamicSize : ${bannerAdSize.isDynamicSize}'); print('isAutoHeightSize : ${bannerAdSize.isAutoHeightSize}');
}
so please if you know what is wrong with my code tell me