Hi,
I’ve got problem with the AdMob plugin. When I call the showInterstitialIfLoaded method, the NullPointerException crashes my app:
E/AndroidRuntime(18094): java.lang.NullPointerException
E/AndroidRuntime(18094): at net.vplay.plugins.admob.AdMobInterstitialItem$3.run(AdMobInterstitialItem.java:85)
...
This can be reproduced within the following project:
import Felgo 3.0
import QtQuick 2.0
import Felgo 3.0
GameWindow {
id: gameWindow
licenseKey: "xxx"
activeScene: scene
screenWidth: 640
screenHeight: 960
Scene {
id: scene
width: 320
height: 480
ButtonVPlay {
text: qsTr("Show ad");
onClicked: adMobInterstitial.showInterstitialIfLoaded();
}
}
AdMobInterstitial {
id: adMobInterstitial
adUnitId: "ca-app-pub-xxxx/xx"
onInterstitialReceived: {
console.debug("[AdMob] Video cached");
}
onInterstitialFailedToReceive: {
console.debug("[AdMob] Video failed to load");
}
Component.onCompleted: {
console.debug("[AdMob] Caching video");
loadInterstitial();
}
function showVideo() {
if(platformSupported && platformLoaded) {
showInterstitialIfLoaded();
} else {
console.debug("[AdMob] Not supported :(");
}
}
}
}
The build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://sdk.felgo.com/maven/' }
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'net.vplay.plugins:plugin-admob:2.+'
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
AndroidManifest:
<application ... android:name="net.vplay.helper.VPlayApplication"
<activity ... android:name="net.vplay.helper.VPlayActivity"
with default permissions. I’ve tried also with custom permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />