I checked almost all the possibility for integrate the app with Facebook rewarded ads for my project. I tried,
- facebook_audience_network 1.0.1 : rewarded ads not supports for IOS in this package
- audience_network 0.0.4 : Works in ios , But in android it throws an error.
- easy_ads_flutter 1.0.6 : always shows the google ads only,
Due to the lack of knowledge I faced a ban from google regarding the ad count per time period, So I need an exact knowledge for integrate the facebook ad.
#In this code I have used the audience network package with a different version in the git,
audience network:
git:
url: https://github.com/marcellocamara/audience_network.git
ref: master
The above code is works in ios , But on android getting error.
Any suggestion is appreciated and I need to implement the facebook rewarded ad in ios and android. In meta documentation the exact documentation of the flutter is not yet to be found. The error I got when running the app in android, while using the audience_network plugin is below,
D/NetworkSecurityConfig(21286): No Network Security Config specified, using platform default
I/Timeline(21286): Timeline: Activity_launch_request time:70399667
W/ActivityThread(21286): handleWindowVisibility: no activity for token android.os.BinderProxy@3f94727
D/ForceDarkHelper(21286): updateByCheckExcludeList: pkg: com.example.sample activity: com.facebook.ads.AudienceNetworkActivity@48f1a72
I/chatty (21286): uid=10447(com.example.sample) identical 2 lines
D/ForceDarkHelper(21286): updateByCheckExcludeList: pkg: com.example.sample activity: com.facebook.ads.AudienceNetworkActivity@48f1a72
D/RenderScript HIDL Adaptation(21286): IRenderScriptDevice::getService()
D/RenderScript HIDL Adaptation(21286): IRenderScriptDevice::getService() returned 0x71555f38a0
D/RenderScript HIDL Adaptation(21286): HIDL successfully loaded.
W/.example.sampl(21286): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/ExoPlayerImpl(21286): Init b7cd089 [ExoPlayerLib/2.8.4] [beryllium, POCO F1, Xiaomi, 29]
W/.example.sampl(21286): Accessing hidden method Landroid/app/ActivityThread;->currentActivityThread()Landroid/app/ActivityThread; (greylist, reflection, allowed)
W/.example.sampl(21286): Accessing hidden field Landroid/app/ActivityThread;->mActivities:Landroid/util/ArrayMap; (greylist, reflection, allowed)
W/.example.sampl(21286): Accessing hidden field Landroid/app/ActivityThread$ActivityClientRecord;->paused:Z (greylist, reflection, allowed)
I/flutter (21286): 9001
I/flutter (21286): Ad could not be presented
W/VideoCapabilities(21286): Unsupported mime image/vnd.android.heic
W/VideoCapabilities(21286): Unsupported mime video/divx
W/VideoCapabilities(21286): Unsupported mime video/divx4
2
W/VideoCapabilities(21286): Unrecognized profile/level 0/3 for video/mpeg2
W/VideoCapabilities(21286): Unsupported mime video/x-ms-wmv
I/OMXClient(21286): IOmx service obtained
D/SurfaceUtils(21286): connecting to surface 0x71925dc010, reason connectToSurface
I/MediaCodec(21286): [OMX.qcom.video.decoder.avc] setting surface generation to 21796865
D/SurfaceUtils(21286): disconnecting from surface 0x71925dc010, reason connectToSurface(reconnect)
D/SurfaceUtils(21286): connecting to surface 0x71925dc010, reason connectToSurface(reconnect)
I/ExtendedACodec(21286): setupVideoDecoder()
I/ExtendedACodec(21286): Decoder will be in frame by frame mode
D/SurfaceUtils(21286): set up nativeWindow 0x71925dc010 for 1280x720, color 0x7fa30c06, rotation 0, usage 0x20002900
W/Gralloc3(21286): allocator 3.x is not supported
I/OMXClient(21286): IOmx service obtained
2
I/ACodec (21286): codec does not support config priority (err -2147483648)
W/ExtendedACodec(21286): Failed to get extension for extradata parameter
V/RenderScript(21286): Successfully loaded runtime: libRSDriver_adreno.so
D/ (21286): Successfully queried cache dir: /data/user_de/0/com.example.sample/code_cache
D/RenderScript(21286): Setting cache dir: /data/user_de/0/com.example.sample/code_cache
E/libc (21286): Access denied finding property "vendor.debug.trace.perf"
D/AudioTrack(21286): set(sessionID=0)
D/AudioTrack(21286): set(): streamType -1, sampleRate 44100, format 0x1, channelMask 0x3, frameCount 14144, flags #0, notificationFrames 0, sessionId 0, transferType 3, uid -1, pid -1
Here is the code throws error
import 'package:audience_network/audience_network.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@override
void initState() {
AudienceNetwork.init(
testingId: "",
testMode: true,
iOSAdvertiserTrackingEnabled: true,
).then((value) {
print('AudienceNetwork init $value');
});
super.initState();
}
void _incrementCounter() {
final rewardedAd = RewardedAd(
RewardedAd.testPlacementId,
);
rewardedAd.listener = RewardedAdListener(
onLoaded: () {
rewardedAd.show();
},
onVideoComplete: () {
rewardedAd.destroy();
print('Video completed');
},
onError: (code, message) {
print(code);
print(message);
},
);
rewardedAd.load();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}