Framework7.use(cordova-plugin-admob-free);
var app = new Framework7({
on: {
init: function () {
var f7 = this;
admob.banner.config({
id: 'ca-app-pub-hidden',
})
// Create banner
admob.banner.prepare()
// Show the banner
admob.banner.show()
Often, when you add plugins to your cordova projects, they are made available either directly on the window object, or on the window.cordova.plugins object.
So, to access your admob plugin, I would try something like this: const admob = window.cordova.plugins.admob or const admob = window.admob
Or from their doc, perhaps a simple import {banner} from 'cordova-plugin-admob-free/admob' would do the trick.
In wish file i can put import {banner} from 'cordova-plugin-admob-free/admob' ?
I don’t understand the structure of a f7’s project.
The doc is clearly not helpfull.
In the component in which you wish to use the banner.
Have you checked the content of the window object to see if it is not already available there?
Anyway, I feel like your issue is more cordova related than it is Framework7 related, no?
This error is generating because --save is getting called on the framework7 point of view not in cordova. Just change into your cordova directory and then you can install the plugin
@vbguyny
framework7 cordova plugin add cordova-plugin-admob-free – --save --variable ADMOB_APP_ID=“ca-app-pub-xxxxxxxxxxxxxxx~xxxxxxxxx” will works
Note the – before the --save.
No Fill is encountered when no ad is being served from google.
Try following steps:-
1)Use tests ads first. In this way you will know whether there is some problem in your code(which i think doesn’t) or simply server is not sending ads.
2)Wait for some time(~24 hours) as it takes some time for server to register that your publisher id is configured.In some cases, it might also take 4~6 days.
I also want to ask how do you test your cordova plugins. Whenever i do some changes to plugin-side, i create debug app and then test it on my android device. This whole process takes a lot time. It would be great if you can give a overview of how you test your plugins.
Ok, so changing the script around to use the Google test ads, I was able to get them to load (see below). I am assuming that means I need to wait some time before the AdMobs has registered my publisher id.
I would be more than happy to create an article or documentation somewhere once I get this working. Creating Android apps with F7-CLI is really simple once you get the hang of it
Just wait for some time. I get it working almost in an instant because my apk(which do not has ads) is already live on play store and i add ad in update. Thanks for sharing your experience. You’re right F7-Cli is more than easy. I tried react-native and nativescript, both of them are not great to start with, even though both of them are native. React Native even have licensing issue.
Sorry for troubling. Now, i’m trying to add cordova-plugin-admob-free in next project. Installation is successful but it generates following error on build:-
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:243: error: cannot find symbol
@NonNull
^
symbol: class NonNull
location: class AdMob
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: 24 actionable tasks: 6 executed, 18 up-to-date
Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5m 40s
Since the issue is plugin related, i guess you may encountered the error too . How did you install it?
@Gagan
Sorry to here. I have been getting that error trying add mediation plugins for AdMob but not the one you are trying to install.
Are you running the latest version of the F7-CLI?
I didn’t, I just didn’t use those plugins. As for the cordova-plugin-admob-free, I am using f7-cli version 3.2.4 with the plugin so I don’t know if that has anything to do with it.
Also, my app got published to the “Internal test track” but I am still not getting live ads in my app. Do I need to publish it to “Production” for it to work?
For all those who may have same error in future, do following:-
1 Remove the plugin
2)remove android platform
3)add android platform
4)re-install the plugin
I do haven’t tried “Internal test track” as i’m currently struggling with downloads. Once you deployed your app to production, it starts loading ads even with app_debug apk