Hi,
Why am I getting a java.lang.NullPointerException when I try the following code in main.lua?
Here is my main.lua. Error occurs at the admob.load line.
local admob = require( "plugin.admob" ) local function admobAdListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.provider ) end end admob.init( admobAdListener, { appId="ca-app-pub-\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*~\*\*\*\*\*\*\*\*\*\*\*\*\*" } ) --Notice the "~" This is correct right? local function onSystemEvent( event ) if ( event.type == "applicationStart" ) then admob.load( "interstitial", { adUnitId="ca-app-pub-\*\*\*\*\*\*\*\*\*\*\*\*\*\*/\*\*\*\*\*\*\*\*\*\*\*\*" } ) end end
Here is the error when deployed on a device. Device is old (API 16) maybe thats the problem but I have successfully managed to load and show ads but in another scene. Why am I getting this error at main.lua?
I/Corona ( 5122): ERROR: Runtime error I/Corona ( 5122): main.lua:707: java.lang.NullPointerException I/Corona ( 5122): Java Stack Trace: I/Corona ( 5122): plugin.admob.LuaLoader$Load.invoke(LuaLoader.java:670) I/Corona ( 5122): com.ansca.corona.JavaToNativeShim.nativeRender(Native Method) I/Corona ( 5122): com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:182) I/Corona ( 5122): com.ansca.corona.Controller.updateRuntimeState(Controller.java:347) I/Corona ( 5122): com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:421) I/Corona ( 5122): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1623) I/Corona ( 5122): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1378)