Ember test fail with `testem.js not loaded?` - javascript

I'm getting below error message mentioned below for an ember project when running tests locally with ember test.
most of time PhantomJS was hanging.
$ ember test
not ok 1 Chrome - error
---
message: >
Error: Browser failed to connect within 30s. testem.js not loaded?
Stderr:
2018-07-13 11:24:43.115 Google Chrome[47537:547312] Errors logged by ksadmin: KSKeyedPersistentStore store directory does not exist. [com.google.UpdateEngine.CommonErrorDomain:501 - '/Library/Google/GoogleSoftwareUpdate/TicketStore' - 'KSKeyedPersistentStore.m:368']
KSPersistentTicketStore failed to load tickets. (productID: com.google.Chrome) [com.google.UpdateEngine.CoreErrorDomain:1051 - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore'] (KSKeyedPersistentStore store directory does not exist. - '/Library/Google/GoogleSoftwareUpdate/TicketStore' [com.google.UpdateEngine.CommonErrorDomain:501])
ksadmin cannot access the ticket store:<KSUpdateError:0x100404060
domain="com.google.UpdateEngine.CoreErrorDomain"
code=1051
userInfo={
function = "-[KSProductKeyedStore(ProtectedMethods) errorForStoreError:productID:message:timeoutMessage:]";
date = 2018-07-13 03:24:43 +0000;
productids = {(
"com.google.Chrome"
)};
filename = "KSProductKeyedStore.m";
line = 102;
NSFilePath = "/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore";
NSUnderlyingError = <KSError:0x100515350
domain="com.google.UpdateEngine.CommonErrorDomain"
code=501
userInfo={
date = 2018-07-13 03:24:43 +0000;
line = 368;
filename = "KSKeyedPersistentStore.m";
function = "-[KSKeyedPersistentStore(PrivateMethods) validateStorePath]";
NSFilePath = "/Library/Google/GoogleSoftwareUpdate/TicketStore";
NSLocalizedDescription = "KSKeyedPersistentStore store directory does not exist.";
}
>;
NSLocalizedDescription = "KSPersistentTicketStore failed to load tickets.";
}
>
[47537:28675:0713/112447.920274:ERROR:ssl_client_socket_impl.cc(1026)] handshake failed; returned -1, SSL error code 1, net_error -107
[47537:28675:0713/112448.006779:ERROR:ssl_client_socket_impl.cc(1026)] handshake failed; returned -1, SSL error code 1, net_error -107
2018-07-13 11:24:52.494 Google Chrome Helper[47600:548065] Couldn't set selectedTextBackgroundColor from default ()
Log: |
{ type: 'error',
text: 'Error: Browser failed to connect within 30s. testem.js not loaded?' }
{ type: 'error',
text: '2018-07-13 11:24:43.115 Google Chrome[47537:547312] Errors logged by ksadmin: KSKeyedPersistentStore store directory does not exist. [com.google.UpdateEngine.CommonErrorDomain:501 - \'/Library/Google/GoogleSoftwareUpdate/TicketStore\' - \'KSKeyedPersistentStore.m:368\']\nKSPersistentTicketStore failed to load tickets. (productID: com.google.Chrome) [com.google.UpdateEngine.CoreErrorDomain:1051 - \'/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore\'] (KSKeyedPersistentStore store directory does not exist. - \'/Library/Google/GoogleSoftwareUpdate/TicketStore\' [com.google.UpdateEngine.CommonErrorDomain:501])\nksadmin cannot access the ticket store:<KSUpdateError:0x100404060\n\tdomain="com.google.UpdateEngine.CoreErrorDomain"\n\tcode=1051\n\tuserInfo={\n\t\tfunction = "-[KSProductKeyedStore(ProtectedMethods) errorForStoreError:productID:message:timeoutMessage:]";\n\t\tdate = 2018-07-13 03:24:43 +0000;\n\t\tproductids = {(\n\t\t\t"com.google.Chrome"\n\t\t)};\n\t\tfilename = "KSProductKeyedStore.m";\n\t\tline = 102;\n\t\tNSFilePath = "/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore";\n\t\tNSUnderlyingError = <KSError:0x100515350\n\t\t\tdomain="com.google.UpdateEngine.CommonErrorDomain"\n\t\t\tcode=501\n\t\t\tuserInfo={\n\t\t\t\tdate = 2018-07-13 03:24:43 +0000;\n\t\t\t\tline = 368;\n\t\t\t\tfilename = "KSKeyedPersistentStore.m";\n\t\t\t\tfunction = "-[KSKeyedPersistentStore(PrivateMethods) validateStorePath]";\n\t\t\t\tNSFilePath = "/Library/Google/GoogleSoftwareUpdate/TicketStore";\n\t\t\t\tNSLocalizedDescription = "KSKeyedPersistentStore store directory does not exist.";\n\t\t\t}\n\t\t>;\n\t\tNSLocalizedDescription = "KSPersistentTicketStore failed to load tickets.";\n\t}\n>\n[47537:28675:0713/112447.920274:ERROR:ssl_client_socket_impl.cc(1026)] handshake failed; returned -1, SSL error code 1, net_error -107\n[47537:28675:0713/112448.006779:ERROR:ssl_client_socket_impl.cc(1026)] handshake failed; returned -1, SSL error code 1, net_error -107\n2018-07-13 11:24:52.494 Google Chrome Helper[47600:548065] Couldn\'t set selectedTextBackgroundColor from default ()\n' }
1..1
# tests 1
# pass 0
# skip 0
# fail 1
Testem finished with non-zero exit code. Tests failed.
testem.js:
/*jshint node:true*/
module.exports = {
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"Chrome"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
};
installed Versions:
MacOS Sierra 10.12.6
node: 6.12.2
npm: 5.6.0
ember: 2.12.0
ember-cli: 2.18.2
phantomjs: 2.1.1
Below is partial of my tests/index.html file:
<script src="testem.js" integrity=""></script>
<script src="assets/vendor.js"></script>
<script src="assets/test-support.js"></script>
<script src="assets/myApp.js"></script>
<script src="assets/tests.js"></script>
also tried with ember test --server but same error.
So anyone has any idea on how to narrow down this and why testem is not getting loaded ?

For tests usually you need to run chrome in headless mode with enabled remote debugging. Adding these lines to your testem.json should help:
"browser_args": {
"Chrome": [
'--headless',
'--disable-gpu',
'--remote-debugging-port=9222',
'--window-size=1440,900',
]
}
I also suggest to remove "PhantomJS" line - phantom may not work with recent ember versions due to this issue.

Changed testem.js with below settings. and its working fine :)
/* eslint-env node */
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
browser_args: {
Chrome: {
mode: 'ci',
args: [
'--disable-gpu',
'--headless',
'--remote-debugging-port=0',
'--window-size=1440,900'
]
}
}
};

If you already checked for the obvious browser settings and it still doesn't work: see if you're setting EMBER_ENV=test.

Related

FundMe project isn't deploying and getting "No deployment found for: MockV3Aggregator"

When I run this command yarn hardhat deploy --tags fundme I'm getting this MockV3Aggregator error.
Error: ERROR processing /Users/mohameduzair/blockChain/JSweb3_2/fundMe_hardhat/deploy/01-deploy-fundMe.js:
Error: No deployment found for: MockV3Aggregator at Object.get (/Users/mohameduzair/blockChain/JSweb3_2/fundMe_hardhat/node_modules/hardhat-deploy/src/DeploymentsManager.ts:162:17)
01-deploy-fundMe.js deploy script
```module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let ethUsdPriceFeedAddress
if (developmentChains.includes(network.name)) {
// if (chainId === 31337) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
log: true,
})
log(`FundMe deployed at ${fundMe.address}`)
log(`-------------------------!!!--------------------------`)
}
module.exports.tags = ["all", "fundme"]
```
MockV3Aggregator.sol contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
// pragma solidity >=0.6.6 <0.8.7;
import "#chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
I', new to the Blockchain technologies. I'm following a tutorial on Youtube. I've tried my best. still can not fix this.
What should I do now?
Thank you
This is Patrick's tutorial, and you need to first deploy the mock.
Please see here.
After spending 5 hours, I fixed the bug. It was an extra {curly brace} in my code and a deployment error.
If you are following Patrick's tutorial and getting this error then you are probably missing network.name in either of deploy files.
Instead of network.name you have typed only network
Instead of
module.exports.tags = ["all", "fundme"]
in 01-deploy-fundMe.js, use
module.exports.tags = ["all", "mocks"]
and then use command
yarn hardhat deploy --tags mocks
;)

PluginError during publication error in parsing: Unexpected token =>

Im trying to make a publication of a webapp into a server(WindowsServer2012), Im using .NET Visual Studio 2019,
When I try to publish it this error pops:
[PluginError: Error in parsing: "Sensores\creadorGraficos.js", Line 14: Unexpected token =>] {
showStack: false,
showProperties: true,
plugin: 'gulp-angular-filesort',
__safety: { toString: [Function: bound ] }
}
Procesar terminados con el código 1.
last sentence translation:
Process ended with code 1
The code is nothing fancy, just a .map :
var presionatmosferica = dataURL.map(function (elemF) {
return elemF.map(o => { return { fecha: o.fecha, presionatmosferica: o.presionatmosferica } })
});
so the problem is the token:
=>
Any idea why this is happening?
By the way, the publication is being made by other PC, my guess was that Gulp was not installed so I run:
npm install gulp
and still the same error.

Pass JWT to rabbitmq over websockets

This is my current RabbitMQ / Stomp setup which works fine with username and password authentication.
My end goal is to pass a JWT instead of username and password. I already have access to the token on the front-end and I do not want to conduct a UAA server. I have added this plugin to RabbitMQ and tried doing what step 3 of the Authorization flow says with no luck.
Client passes the token as password when connecting to a RabbitMQ
node. The username field is ignored.
I get the following error:
<<< ERROR
content-length:16
version:1.0,1.1,1.2
content-type:text/plain
message:Processing error
content-length:16
Edit
Another observation is that after adding "Authorization: Bearer" in front of the token I get the a new error.
<<< ERROR
content-length:33
version:1.0,1.1,1.2
content-type:text/plain
message:Bad CONNECT
content-length:33
Access refused for user 'rabbit'
RabbitMQ Setup
Docker
FROM rabbitmq
RUN rabbitmq-plugins enable --offline rabbitmq_management
RUN rabbitmq-plugins enable --offline rabbitmq_stomp
RUN rabbitmq-plugins enable --offline rabbitmq_web_stomp
RUN rabbitmq-plugins enable --offline rabbitmq_auth_backend_oauth2
COPY ./advanced.config /etc/rabbitmq/advanced.config
COPY ./rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
EXPOSE 15671 15672 15674 61613
advanced.config
[
{rabbit, [
{default_user, <<"admin">>},
{default_pass, <<"guest">>},
{auth_backends, [rabbit_auth_backend_oauth2, rabbit_auth_backend_internal]}
]},
{rabbitmq_management, [
{enable_uaa, false}
]},
{rabbitmq_auth_backend_oauth2, [
{resource_server_id, <<"rabbitmq">>},
{key_config, [
{default_key, <<"key-1">>},
{signing_keys,
#{<<"key-1">> => {pem, <<"-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAr8xZBLjW7yMZJobc/IFo
6New9jlCvSx8I6aSBrU+EU+TN6iXF13Tqqp62L/TWlTrYlErsu2yvLknhN4VU7qX
g38/2wZn9/kKFYCkeaDe3lDxl+4rNGq1TSEXCzndIDfVzgxZvKZ0Vt5+mvr1cxR7
7V6MFcJvIHMv4MdIqAUwABFFHvonp56yzh7g/UsAk6XlaqhoZQ1NrPyWpG6YgHwg
hFibyh0ZI3gD7H0UshpR9VVPLTgrAUnf3qWMpEXKO2ePmrTVwwDpL25n5DdhaBz6
e+YSonTT7KigxeklRPrKc7km29l0frml+8jOsQsx7L2WCD/HqR6J5iVDZ5mDfeKN
vcixi+nkLTCyV1jsHEzteSmGgmAE6SrSMXV+oPz2xLGKEGJJQWS+Ll1l5BD1MmZE
6DqLoe8FHew54M7zniCxkhDIHcpVY3IYcv2gohhaxm9MHkSHaj6bwAGQcORwgGho
ETVr7RXyvCD5Vsr6VqDqknjleP1tLi/gnlzP099SLmGiB6y/v1mW1s3tDpI/F7b7
WWDyHRqW9YfGEPYOmNdELcizW9UxY2MFvK4LlacRaXzzDEXmiP/FK84Qse14Nmyi
6tfqIYe+PRWbA7ztOaBlmDnkhxHcLufB48t4dleUWmj+6VOXQGXef10p4rQNeOo5
N5dJoYqveUJ6Lfln3C25NJcCAwEAAQ==
-----END PUBLIC KEY-----">>}
}
}]
}
]}
].
rabbitmq.conf
loopback_users.guest = false
total_memory_available_override_value = 2684354560
listeners.tcp.default = 5672
management.tcp.port = 15672
web_stomp.ws_frame = binary
Current Stomp client setup
var client = new StompJs.Client({
brokerURL: 'ws://localhost:5900/ws',
connectHeaders: {
login: 'admin',
passcode: 'guest'
},
debug: log => (
console.log(
log
)
),
reconnectDelay: 5 * 1000,
heartbeatIncoming: 4 * 1000,
heartbeatOutgoing: 4 * 1000,
});
Ideal JWT setup
var client = new StompJs.Client({
brokerURL: 'ws://localhost:5900/ws',
connectHeaders: {
login: 'rabbit',
passcode: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0FjdGl2ZSI6dHJ1ZSwiX2lkIjoiNWZkNzc0MDY4NzE3NTU2OWFlMTIxNmRmIiwiY29kZSI6IjIwMDAwMDEwNiIsInVzZXJuYW1lIjoiYW50b25pc2NvZGV1cCIsImVtYWlsIjoiYW50b25pc0Bjb2RldXAuc29mdHdhcmUiLCJmaXJzdE5hbWUiOiJBbnRvbmlzIiwibGFzdE5hbWUiOiJQaXNoaWFzIiwib3JnYW5pc2F0aW9uIjoiQ29kZVVwIFNvZnR3YXJlIEx0ZCIsInJvbGUiOnsiX2lkIjoiNWZkMmEyM2VjOTJmOTFjNTFkOTIzMTZiIiwibmFtZSI6ImN1c3RvbWVyIiwicmVhZCI6W3siX2lkIjoiNWZkMmEyM2VjOTJmOTFjNTFkOTIzMTViIiwibmFtZSI6ImFjY291bnRzIn0seyJfaWQiOiI1ZmQyYTIzZWM5MmY5MWM1MWQ5MjMxNWMiLCJuYW1lIjoiY3JtIn0seyJfaWQiOiI1ZmQyYTIzZWM5MmY5MWM1MWQ5MjMxNWQiLCJuYW1lIjoid2FyZWhvdXNlIn1dLCJjcmVhdGUiOltdLCJ1cGRhdGUiOltdLCJtb3ZlIjpbXSwiX192IjowfSwiX192Ijo3LCJzY29wZXMiOlsicmFiYml0bXEuY29uZmlndXJlOiovKiIsInJhYmJpdG1xLndyaXRlOiovKiIsInJhYmJpdG1xLnJlYWQ6Ki8qIl0sImlhdCI6MTYwNzk1NjkzNCwiZXhwIjoxNjA4NTYxNzM0LCJhdWQiOlsiaHR0cHM6Ly9iaXpjb3VyaWVyLmV1IiwicmFiYml0bXEiXSwiaXNzIjoiaHR0cHM6Ly9yZXN0LmJpemNvdXJpZXIuZXUifQ.Ypqa16YuqH3rfwxAQZ_RdJRF21h6jYX07r-zaB3AP_qshU_xBiP9RpFvFkws13i0_X3Ou-qKxSdAF51T1t-Ob5V4LiXLJKsesmZIeIGXs-Dhc79u5UqhOdGIzPgRTlieOIUmrFKsPBWf7FnoR-lgd9gH8ge3Wp2f2vOqU24JsEjkvtlTGLS1aId27UVz0d2qxMLWf-9kLxW4mmuM2UCeRsnznpPaZbAfhq2tHHIy3EtGeIIiOsAE0lM9BfJRF36kjZcpcMZSnhTrkZjiDsrUuiVd-W27MVJRYFVpULkGrpa5RkkDG5ZbwNNSn0VUMZB2PiQTchtNyoffutPzhktxieDO5T0OzrSXl5VAtgZFHi5oPLWtPGVejNiWMFsY9u1ale6NRDSReeQjPPEqzpH-tfnugkwyv_jhL6WnfmoeEBgcuyK7eBvrg7uJbQFdwMrRQXkGn_ATn0XhJWI-Hia3muNbNbvdL0jgkZBv0HFPsx84n3-IEx672_6Wy2qtLtFcnUgGr4ThRVp8PE0ro21JdvjFbwgq9k5Qhv5MA6wgB6nt7vtuP1SZ17ekIPE6izwHUPZsWsqJg6v108H1B13J2yxK5LcdsCb8Z8uRhiRSKt4Cs6MHsZg0GCOjym2YHXyN21Wpw3behq0GxUiSrU4qkADujDb6nNzaLq2_ecn5bOI'
},
debug: log => (
console.log(
log
)
),
reconnectDelay: 5 * 1000,
heartbeatIncoming: 4 * 1000,
heartbeatOutgoing: 4 * 1000,
});
You can decode the JWT here
I think that you are missing a scope in your JWT
See the documentation here:
https://github.com/rabbitmq/rabbitmq-server/tree/master/deps/rabbitmq_auth_backend_oauth2
It says:
Token scope returned by OAuth 2.0 provider must include RabbitMQ resource scopes that follow a convention used by this plugin: configure:%2F/foo means "configure permissions for 'foo' in vhost '/'") (scope field can be changed using extra_scopes_source in advanced.config file.
(BTW: I coudn't find the "extra_scopes_source" in your advanced.config as well)
Although I didn't test it, failing to provide the scope would logically result in an access denied error.

FBSDK: Cannot read property loginwithreadpermissions of undefined

I'm setting up a React Native project using the FBSDK for login purpose.
Here's what I've done so far:
I ran npm install react-native-fbsdk --save
I ran react-native link
I followed each step mentioned there: https://developers.facebook.com/docs/facebook-login/ios/
I double checked using this video: https://www.youtube.com/watch?v=rAXVKapP5cM
However, I still get this red screen error:
Cannot read property logInWithReadPermissions of undefined at FBLoginManager.js, line 77 (https://github.com/facebook/react-native-fbsdk/blob/master/js/FBLoginManager.js)
Here's my AppDelegate.m content:
#import "AppDelegate.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:#"PegaseBuzzApp"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
#end
Here's my linked frameworks and binaries:
EDIT: on my project:
const FBSDK = require('react-native-fbsdk');
const {
LoginManager,
} = FBSDK;
Plus:
_onFBButtonPress () {
LoginManager.logInWithReadPermissions(['public_profile']).then(
function(result) {
if (result.isCancelled) {
alert('Login cancelled');
} else {
alert('Login success with permissions: '
+result.grantedPermissions.toString());
}
},
function(error) {
alert('Login fail with error: ' + error);
}
);
}
And:
<Button onPress={() => this._onFBButtonPress()} buttonStyle={'buttonFb'} labelStyle={'buttonFbText'} label={I18n.t('Login.btnConnectFB')}></Button>
What do I miss?
I just resolved the same error.
For some reason
"react-native link react-native-fbsdk"
had finished for Android but not ios.
rnpm-install info Android module react-native-fbsdk is already linked
rnpm-install info Linking react-native-fbsdk ios dependency
rnpm-install info iOS module react-native-fbsdk has been successfully linked
Try rerunning and make sure you are linking with
libRCTFBSDK.a
Following #Greg Cockroft's answer, I've noticed that I was not being able to include "libRCTFBSDK.a" on my project's "Link Binary With Libraries" because I was not including the "RCTFBSDK" library project.
So if you are on same situation do the following missing steps:
Add (or drag using Finder) "/node_modules/react-native-fbsdk/ios/RCTFBSDK.xcodeproj" under your Xcode project "Libraries" group.
Build "RCTFBSDK.xcodeproj" or your entire project.
Add "libRCTFBSDK.a" on your project settings, under "Link Binary With Libraries".
Compile/run your app. Now if you have the right JS login code, you should be able to login via Facebook's screen.
Use the function LoginManager.logInWithPermissions(['public_profile', 'email']);
Once you did this:
npm install react-native-fbsdk --save
react-native link
Download latest FacebookSDK to your ~/Documents folder.
Unzip it to ~/Documents/FacebookSDK/
Then rebuild in XCode.
Works for me.
solved by adding to metro.config.js. And make sure you have installed metro-config
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
])
},
};

FileOpener2 causing Attempt to invoke virtual method in cordova.js file on Android 6.0 or higher

We use FileOpener2 plugin for cordova to open a downloaded .apk file from our servers. Recently, we found that Android 6.0 or higher devices are throwing an exception only on the file open process. We were able to trace this down to the cordova.js file, where the posted exception occurs. We have yet to find a cause or a fix, but have put a workaround in place. Any info would be amazing on this so we can maintain our in-app self updating process going on all Android devices.
Code (Working on Android <= 6.0):
// we need to access LocalFileSystem
window.requestFileSystem(LocalFileSystem.PERSISTENT, 5 * 1024 * 1024, function (fs) {
//Show user that download is occurring
$("#toast").dxToast({
message: "Downloading please wait..",
type: "warning",
visible: true,
displayTime: 20000
});
// we will save file in .. Download/OURAPPNAME.apk
var filePath = cordova.file.externalRootDirectory + '/Download/' + "OURAPPNAME.apk";
var fileTransfer = new FileTransfer();
var uri = encodeURI(appDownloadURL);
fileTransfer.download(uri, filePath, function (entry) {
//Show user that download is occurring/show user install is about to happen
$("#toast").dxToast({
message: "Download complete! Launching...",
type: "success",
visible: true,
displayTime: 2000
});
////Use pwlin's fileOpener2 plugin to let the system open the .apk
cordova.plugins.fileOpener2.open(
entry.toURL(),
'application/vnd.android.package-archive',
{
error: function (e) {
window.open(appDownloadURL, "_system");
},
success: function () { console.log('file opened successfully'); }
}
);
},
function (error) {
//Show user that download had an error
$("#toast").dxToast({
message: error.message,
type: "error",
displayTime: 5000
});
},
false);
})
Debugging Information:
THIS IS NOT OUR CODE, BUT APACHE/CORDOVA CODE
Problem File: cordova.js
function androidExec(success, fail, service, action, args) {
// argsJson - "["file:///storage/emulated/0/download/OURAPPNAME.apk","application/vnd.android.package-archive"]"
//callbackId - FileOpener21362683899
//action - open
//service FileOpener2
//bridgesecret - 1334209170
// msgs = "230 F09 FileOpener21362683899 sAttempt to invoke virtual method 'android.content.res.XmlResourceParser //android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference"
var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
// If argsJson was received by Java as null, try again with the PROMPT bridge mode.
// This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "#Null arguments.") {
androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
androidExec(success, fail, service, action, args);
androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
} else if (msgs) {
messagesFromNative.push(msgs);
// Always process async to avoid exceptions messing up stack.
nextTick(processMessages);
}

Categories

Resources