file:///android_asset/www/cordova_plugins.js Failed to load resource: net::ERR_FILE_NOT_FOUND
I have researched this and it seems from everything I have read it something on your end, I am referencing cordova.js not phonegap.js and I am still experiencing this issue.
I have researched this and it seems from everything I have read it something on your end, I am referencing cordova.js not phonegap.js and I am still experiencing this issue.
- 27 Posts
- 0 Reply Likes
Posted 4 years ago
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Could you please confirm:
- that you are building with Phonegap Build. No local build.
- that your config.xml and index.html are both in the root directory of your zip file
- that you reference cordova.js this way:
- that the error occurs in the index.html, not in a different html document inside a subdirectory
- that you are building with Phonegap Build. No local build.
- that your config.xml and index.html are both in the root directory of your zip file
- that you reference cordova.js this way:
<script src="cordova.js"/>
- that the error occurs in the index.html, not in a different html document inside a subdirectory
- 27 Posts
- 0 Reply Likes
Yes I am referencing in that manner, I managed too figure out the problem I forgot to reference plugins, although now I am receiving the error,
Uncaught TypeError: Cannot read property 'getCurrentAcceleration' of undefined
Uncaught TypeError: Cannot read property 'getCurrentAcceleration' of undefined
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Are you waiting for the deviceready event to fire before invoking that method?
- 27 Posts
- 0 Reply Likes
yes I tried two different syntax's, with this syntax my device does nothing but I get no error
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
startWatch();
}
with this I get the error
document.addEventListener("deviceready", onDeviceReady(), false);
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
startWatch();
}
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
startWatch();
}
with this I get the error
document.addEventListener("deviceready", onDeviceReady(), false);
function onDeviceReady() {
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
startWatch();
}
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Of course. The latter is wrong. You can't call the callback function yourself...it must be done by the eventlistener.
In the former syntax, how do you define the success callback?
In the former syntax, how do you define the success callback?
- 27 Posts
- 0 Reply Likes
as such
function onSuccess(acceleration) {
var accelerationChange = {};
if (previousAcceleration.x == null && previousAcceleration.y == null && previousAcceleration.z == null) {
previousAcceleration.x = acceleration.x;
previousAcceleration.y = acceleration.y;
previousAcceleration.z = acceleration.z;
} else {
var accelerationDelta = {
x: acceleration.x - previousAcceleration.x,
y: acceleration.y - previousAcceleration.y,
z: acceleration.z - previousAcceleration.z
}
var maginitude = Math.sqrt(
Math.pow(accelerationDelta.x, 2) +
Math.pow(accelerationDelta.y, 2) +
Math.pow(accelerationDelta.z, 2)
);
if (maginitude >= 12) {
rollDice();
stopWatch();
setTimeout(startWatch, 1000);
previousAcceleration = {
x: null,
y: null,
z: null
}
} else {
previousAcceleration = {
x: acceleration.x,
y: acceleration.y,
z: acceleration.z
}
}
}
}
function onSuccess(acceleration) {
var accelerationChange = {};
if (previousAcceleration.x == null && previousAcceleration.y == null && previousAcceleration.z == null) {
previousAcceleration.x = acceleration.x;
previousAcceleration.y = acceleration.y;
previousAcceleration.z = acceleration.z;
} else {
var accelerationDelta = {
x: acceleration.x - previousAcceleration.x,
y: acceleration.y - previousAcceleration.y,
z: acceleration.z - previousAcceleration.z
}
var maginitude = Math.sqrt(
Math.pow(accelerationDelta.x, 2) +
Math.pow(accelerationDelta.y, 2) +
Math.pow(accelerationDelta.z, 2)
);
if (maginitude >= 12) {
rollDice();
stopWatch();
setTimeout(startWatch, 1000);
previousAcceleration = {
x: null,
y: null,
z: null
}
} else {
previousAcceleration = {
x: acceleration.x,
y: acceleration.y,
z: acceleration.z
}
}
}
}
- 27 Posts
- 0 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Does your code execution actually reach the line
If so, what are the object type values for
navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
If so, what are the object type values for
navigator.accelerometer and for navigator.accelerometer.getCurrentAcceleration?- 27 Posts
- 0 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
So, the deviceready event never fires.
I could ask 20 more questions now, but it would be better to see your project. Is your zip file available online somewhere? If so, please post its url and I'll be happy to have a look.
I could ask 20 more questions now, but it would be better to see your project. Is your zip file available online somewhere? If so, please post its url and I'll be happy to have a look.
- 27 Posts
- 0 Reply Likes
- 27 Posts
- 0 Reply Likes
The weird thing about this is I managed to get the application to work with Ripple emulator.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Ah, there we are. Your config is all wrong.
This will do nothing without the whitelist plugin from npm, unless you are building with PGB3.x (which you are, but you shouldn't; use at least cli-5.2.0)
That's an ancient plugin version. Use the latest plugin from npm. Be aware that it is named differently (cordova-plugin-device).
That's an ancient plugin version. Use the latest plugin from npm. Be aware that it is named differently
That plugin doesn't exist at pgb.. Use the latest plugin from npm.
Yeah, right. 3.6.3 is almost two years old. You can't use that anymore.
Feature elements are obsolete. Also, you don't need it if you have a proper device plugin referenced.
Note: your config is lacking icons and splashes. For Android: strongly recommended, for iOS (which you aren't building now) required.
<access origin="*"/>
This will do nothing without the whitelist plugin from npm, unless you are building with PGB3.x (which you are, but you shouldn't; use at least cli-5.2.0)
<gap:plugin version="0.2.12" name="org.apache.cordova.device" source="pgb"/>
That's an ancient plugin version. Use the latest plugin from npm. Be aware that it is named differently (cordova-plugin-device).
<gap:plugin version="0.5.2" name="org.apache.cordova.inappbrowser" source="pgb"/>
That's an ancient plugin version. Use the latest plugin from npm. Be aware that it is named differently
<gap:plugin name="cordova-plugin-device-motion" source="pgb" spec="1.1.1"/>
That plugin doesn't exist at pgb.. Use the latest plugin from npm.
<!-- Use the newest version of PhoneGap -->
<preference name="phonegap-version" value="3.6.3"/>
Yeah, right. 3.6.3 is almost two years old. You can't use that anymore.
<!-- Device permission is needed -->
<feature name="http://api.phonegap.com/1.0/device"/>
Feature elements are obsolete. Also, you don't need it if you have a proper device plugin referenced.
Note: your config is lacking icons and splashes. For Android: strongly recommended, for iOS (which you aren't building now) required.
- 27 Posts
- 0 Reply Likes
Thank-you very much for your help, I am very new to this, I actually ended up making my own splash page cause I wanted to use an animated gif, not sure if this is frowned upon though.
- 27 Posts
- 0 Reply Likes
So now my code works on the first dice roll, but afterwards it does nothing.
- 27 Posts
- 0 Reply Likes
It just loops in this block of code inside of accelerometer.js,
timers[id] = {
timer: window.setInterval(function () {
if (accel) {
successCallback(accel);
}
}, frequency),
listeners: p
};
timers[id] = {
timer: window.setInterval(function () {
if (accel) {
successCallback(accel);
}
}, frequency),
listeners: p
};
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
- 27 Posts
- 0 Reply Likes
- 27 Posts
- 0 Reply Likes
- 27 Posts
- 0 Reply Likes
its triggered by the navigator.accelerometer.watchAcceleration(onSuccess, onError, options); function it seems the accelerometers stop working after the first call.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
I'm totally lost.
Why are you doing that? You should simply use the documented api functions from the plugin's docs. The internals of the plugin should be an uninteresting black box to you.
Just start navigator.accelerometer.watchAcceleration (with the options parameters as desired) and act upon the results in the success callback function.
Why are you doing that? You should simply use the documented api functions from the plugin's docs. The internals of the plugin should be an uninteresting black box to you.
Just start navigator.accelerometer.watchAcceleration (with the options parameters as desired) and act upon the results in the success callback function.
- 27 Posts
- 0 Reply Likes
- 27 Posts
- 0 Reply Likes
my debuger gets stuck in the plugin and the success function won't fire, it works in an emulator though.
- 27 Posts
- 0 Reply Likes
this is my start watch function
function startWatch() {
watchId = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
}
the code gets here and then never hits the success function except for the first time.
function startWatch() {
watchId = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
}
the code gets here and then never hits the success function except for the first time.
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers

