Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cannot read property of 'setAttribute' with cordova.js

Hello everyone, this is my first time posting so please bare with me.

The background and setup of the issue:
I was able to compile my test Twine 2 game using both Harlowe and Sugarcube and create an Android app using Phonegap, with no issues. The game mechanics and everything worked fine.

The issue:
when i implemented google admob ads, i started getting the error message which basically says "something is a mess with the page code: Cannot read property of 'setAttribute' with cordova.js using both Harlowe and Sugarcube.

the exact error is:

Uncaught TypeError: Cannot read property 'setAttribute' of null. The error is stemming from the cordova.js script that Admob references. The odd thing is, if you click the error ok button, the error goes away, the game loads, and the ads are displayed without a problem.

Is there a workaround with this? Or at the minimum a way of disabling the Twine error that comes up? everything seems to be working correctly, except for the error.

Any thoughts? Thanks in advance everyone.

Comments

  • Sad no one answered this one. I'm now having a similar issue. Was it ever solved?
  • Kinda hard to answer this with no idea what the code looks like, especially when you have three technologies stacked on top of one another. There is no setAttribute call in cordova.js itself, which suggest it's being caused by an event attachment from admob.

    I don't know which one or where that would be though. I presume it's being caused by the DOM being changed radically in Twine. Maybe an attempt to attach events to the loading screen but, since the game's already loaded, the DOM for it is already gone. At least that's my best guest with no ability to inspect what's going on under the hood.

    Your best option is to pick this thing apart the hard way via dev tools and see where the error is coming from. O, if it is what I suspect, prevent initialization of admob until twine has loaded the story. I haven't looked into how complex this all is as I'm not quite ready to build for mobile. But I can't imagine it's impossible to solve.
  • Based solely on the error. Something is attempting to call the <Element>.setAttribute() method on a element which does not exist. As noted by MoLoLu, without knowing what the code actually looks like, it's extremely difficult to say more.

    If I were to hazard a guess, it's probably that the bit of code in question is making an unfounded assumption about the current state of the DOM—i.e. it assumes that a particular element will exist and the error results from it not existing. As to why the element doesn't exist, there could be any number of reasons, though the likeliest are either user error—the author has set something up incorrectly—or one of the libraries in question is being loaded improperly for the environment—the environment here being within the story format.
Sign In or Register to comment.