1

i'm using the nativescript-admob plugin with nativescript-vue. when i run i get this error :

JS: 'admob createBanner error: Error: java.lang.NullPointerException: Attempt to invoke virtual method \'android.content.res.Resources android.content.Context.getResources()\' on a null object reference'

my code:

 created(){
            return this.banner();
        },
methods: {
            banner(){
                 admob.createBanner({
                    testing: true,
                    size: admob.AD_SIZE.SMART_BANNER, 
                    androidBannerId: "ca-app-pub-3940256099942544/6300978111", // add your own
                    margins: {
                        //top: 10
                        bottom: 50
                    },
                    keywords: ["keyword1", "keyword2"] // add keywords for ad targeting
                }).then(
                    function() {
                        console.log("admob createBanner done");
                    },
                    function(error) {
                        console.log("admob createBanner error: " + error);
                    }
                )
},
aziza
  • 23
  • 3

1 Answers1

0

I fixed the problem by putting this.banner(); in the click of a button in my app instead of created()

aziza
  • 23
  • 3