Mi js only work in android 5.0

  • 1
  • Problem
  • Updated 4 years ago
I dunno why, but my javascript only works in android 5.0, with < preference name="android-minSdkVersion" value="14"/>
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@AlaTrece
Since this appears to be your first posting, please answer the following questions.
- is this your first hybrid mobile app?
- are you using phonegap desktop app?
- Are you using CLI, Build or SDK? Please do not assume the answer. Please read the link.

Thanks
Jesse
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
-yes
-Im using phonegap build
-Build
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What is the difference with this thread:
http://community.phonegap.com/nitobi/...
...in which became apparent, that you had a bunch of javascript mistakes and 'docs interpretation errors'?

Is it a again a specific part of your javascript that "doesn't work", or did you observe that no single javascript code line was executed on Android4.x?
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
the difference is about wich parts doesnt work, the other thread was about media and onload or deviceready event, and all about this is fixed. right now it is the main function of my js wich doesnt work, but it is really weird that my app works perfectly in some android versions and dont work at all in other versions, exist some events or something in js non-supported by android?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Well, the webview components interprete your code. There are many flavors/versions of webview components, and some of them are more relaxed towards syntax errors than others (just like browsers).

Why don't you just post a part of code that "doesn't work", preferably with the javascript errors you receive, or at least the exact spot where the script fails.
Any debug results would be helpful, too.
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
function renderBalls(){

var grid = document.getElementById("main_grid");
//Limpiamos las bolas del nivel anterior
while (grid.firstChild) {
grid.removeChild(grid.firstChild);
}

for(var i = 0; i < Object.keys(balls).length; i++){ ;
var ball = balls[Object.keys(balls)[i]];
var view = document.createElement("div");
view.className = "view";
view.style = "top: " + (ball.y * 75 ) + "px; left: " + (ball.x * 75 ) + "px";
view.id = "bola"+ball.x+ball.y;

var plane_main = document.createElement("div");
plane_main.className = "plane main";

for(var j = 0; j < 6; j++){ ;
var circle = document.createElement("div");
circle.className = "circle";
plane_main.appendChild(circle);
var aro = document.createElement("img")
aro.src = "images/aro"+ball.category+".svg";
circle.appendChild(aro);
}
view.appendChild(plane_main);

var overlay = document.createElement("div");
overlay.style = "width: 100%; height: 100%; position: absolute; top: 0";
/*overlay.addEventListener('touchend', onClickListener, false);*/
view.appendChild(overlay);

grid.appendChild(view);
}
}
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
this is a function to create and position balls for my game, but the line:
view.style = "top: " + (ball.y * 75 ) + "px; left: " + (ball.x * 75 ) + "px";
doesnt work, all of the balls were in the same position, and in android 5.0, all the balls are positioning correctly
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Have you tried debugging by looking at the parts, as in:

...
alert("ball.y: type=" + typeof ball.y + " and value=" + ball.y);
alert("ball.x: type=" + typeof ball.x + " and value=" + ball.x);
alert("calculated values y and x: " + (ball.y * 75 ) + "/" + (ball.x * 75 ));
view.style = "top: " + (ball.y * 75 ) + "px; left: " + (ball.x * 75 ) + "px";
...
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
yes, I tried, everything is calculated properly, every id is givven to its correct ball, but no styles are given to it.
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
Another fail to correct is about "touchend" event, it doesn't work. Click events doesnt work either.
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
no errors, just i cant tap on them
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Sure you can. You did many times.
It's just that you observe that "nothing happens" (at least according to the user).
But you're the developer, so you will have taken a closer look. What is happening in reality?
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
it seems like there are no touchend events. No errors on console, nothing happens when I tap on it, it simply seems like doesnt exist
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
It should work according to.http://www.quirksmode.org/mobile/tabl...

However, if you google it, you'll find posts like http://stackoverflow.com/questions/29...
Photo of AlaTrece Smite

AlaTrece Smite

  • 28 Posts
  • 0 Reply Likes
I have been googling like for a month, then, I started to write here looking for some support. I cannot make it work, however, thx for ur help.