Cordova CLI 5.0.0 - JavaScript error BlankCordovaApp - visual-studio-cordova

I am using the JavaScript Blank Apache Cordova App. Changes were made to the config.xml only.
I changed the Cordova CLI in config.xml from 4.3.0 to 5.0.0. NPM downloaded the files, and no errors were reported.
When I F5 Debug > Android > Ripple. I get the following:
"Exception occurred". Uncaught Error: cordova already defined
This error does not appear when running 4.3.0. Any thoughts on why is would happen in 5.0.0?

Unfortunately this is a known issue with Ripple and the Android implementation in Cordova 5.0.0. The next point release will resolve it as the fix has been merged.
See the following dev mailing list thread on Cordova for details if you are interested: http://callback.markmail.org/message/so6xavs6xdfn45zv?q=+list:org%2Eapache%2Eincubator%2Ecallback-dev+Ripple
UPDATE: Cordova 5.1.1 is out and resolves this problem along with an Android security issue.

A bit late, but this usually works for me. For testing purposes (not only this case, but most of errors that sometimes occur in ripple) I always give it a first try, just like:
---->line 104 on cordova.js (which you can find inside platform www)
replace
if ("cordova" in window) { throw new Error("cordova already defined"); };
With:
if ("cordova" in window) {
//check if emulation
if(window.location.href.indexOf('localhost:4400') < 0){
//if not emulating, throw error
throw new Error("cordova already defined");
}
};
If it doesn't work, then I start googling about the issue.
hope this helps somebody to save some time.

Related

Meteor 1.9 build broken with rollup enabled

I'm getting following error in my Angular Meteor project:
TypeError [ERR_INVALID_ARG_VALUE] [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '\u0000commonjs-proxy:/builds/intemp/in-pool/node_modules/core-js/internals/package.json'
at readFile (fs.js:295:10)
at go$readFile (/home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:110:14)
at Object.readFile (/home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:107:12)
at next (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:98:12)
at load_shims (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:116:7)
at resolve (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/browser-resolve/index.js:236:5)
at /home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:66:5
at new Promise (<anonymous>)
at Object.resolveId$1 [as resolveId] (/home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js:63:11)
at resolveId (packages/angular-typescript-compiler/rollup.js:52:26)
at /home/meteor/.meteor/packages/mibto_angular-compilers/.0.3.4.1i9jtu1.vtaoi++os+web.browser+web.browser.legacy+web.cordova/plugin.Angular_Compilers.os/npm/node_modules/meteor/angular-typescript-compiler/node_modules/rollup/src/utils/first.js:8:31
at /home/meteor/.meteor/packages/meteor-tool/.1.9.0.1mtsmz6.qnno++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/fiber_pool.js:43:40 {
code: 'ERR_INVALID_ARG_VALUE'
}
I'm running following command to build:
METEOR_DISABLE_OPTIMISTIC_CACHING=1 ROLLUP=1 AOT=1 BABEL_CACHE_DIR=/tmp meteor build ../output
without rollup it works, and it also worked before Meteor 1.9
Does anyone have any ideas how to resolve this?
I don’t think rollup=1 has ever worked properly in the angular-meteor compilers. I vaguely remember ardatan mentioning it in a github issue but can’t locate the exact one. The documentation still states it as an option but I think you should forget about it unless you want to fix the specific compiler issue.
Meteor 1.9 is a big upgrade as it uses node 12 so I would not be surprised if this has introduced an issue in the angular compilers package. It probably needs a few tweaks to bring it up to date.

ERROR: Project with path ':#react-native-firebase_app' could not be found in project ':#react-native-firebase_auth'

After install react-native-firebase and add module auth, showed this erro in Android Studio:
ERROR: Project with path ':#react-native-firebase_app' could not be
found in project ':#react-native-firebase_auth'.
What does this mean?
I have also faced the same issue.
After I install npm i #react-native-firebase/app the problem is solved.
You can try the following:
-Checking if firebase app was referenced in an incorrect way in MainApplication.java.
-Remove the modules and re-installing them may fix the problem sometimes.
I think you have different versions of firebase/app and firebase/auth.
Just go in 'node module/#react-native-firebase' directory and check package json of both firebase/app and firebase/auth you will see different version.
This problem can also happen if you are using #react-native-firebase#6.2.0
if you check the build.gradle of firebase/auth in version 6.2.0
dependencies {
api project(':#react-native-firebase_app')
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-auth"
}
So here is a problem that it is not able to find #firebase/app
and #firebase/auth depends on #firebase/app
And in #6.3.4 which is working fine for me have build.gradle of #firebase/auth like below
so it is able to find #firebase/app
if (findProject(':#react-native-firebase_app')) {
api project(':#react-native-firebase_app')
} else if (findProject(':react-native-firebase_app')) {
api project(':react-native-firebase_app')
} else {
throw new GradleException('Could not find the react-native-firebase/app package, have you installed it?')
}
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-auth"
}
run npm uni #react-native-firebase/auth
then run this simple command #react-native-firebase/auth#10.4.1
I was using "#react-native-firebase/auth": "15.1.1", and having the same problem , then i downgrade it to "#react-native-firebase/auth": "^10.4.1", and it worked.
if you have any problem installing make sure to use --legacy-peer-deps at the end , like this:
npm i #react-native-firebase/auth#10.4.1 --legacy-peer-deps

basic React Native SQLite script returning undefined which causes error

I'm trying to learn to use react-native-sqlite-storage as described on this page here:
https://github.com/andpor/react-native-sqlite-storage
I am working on a windows machine trying to build an android app. I have the following code:
import SQLite from 'react-native-sqlite-storage';
function errorCB(err) {
console.log("SQL Error: " + err);
}
function successCB() {
console.log("SQL executed fine");
}
function openCB() {
console.log("Database OPENED");
}
var db = SQLite.openDatabase("test.db", "1.0", "Test Database", 200000, openCB, errorCB);
db.transaction((tx) => {
tx.executeSql('SELECT * FROM Employees a, Departments b WHERE a.department = b.department_id', [], (tx, results) => {
console.log("Query completed");
});
});
export default 1;
When I run this, I get the error
undefined is not an object (evaluating
'NativeModules["SQLite"][method]')
The error is happening on the line var db = SQLite.openDatabase("test.db", "1.0", "Test Database", 200000, openCB, errorCB);
I suspect the reason the error is happening is because SQLite expects the existence of a database before you can actually open it. However, I do not see any instructions in the link above on how to create a database with react-native-sqlite-storage, so I'm not sure if my assumption is correct. Additionally, I assume I'd need to have a table for Employees, but again, the link above didn't explicitly state examples on how to create one. SO I don't know if my assumption is correct.
So how do I get SQLite.openDatabase() command to work?
More information
I deleted my project. Then I tried to re-install everything again, this time closely following the installation instructions for sqlite storage for android as mentioned on the andpor's github instructions (ie, modifying gradle files, updating MainApplication class etc...). Once I did that, running the command react-native run-android from the CLI causes this build error:
ERROR EPERM: operation not permitted, lstat 'C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar'
{"errno":-4048,"code":"EPERM","syscall":"lstat","path":"C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar"}
Error: EPERM: operation not permitted, lstat 'C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar'
at Error (native)
I tried running this command as a regular user and as an administrator, and still the same issue.
More Information 2
I deleted my project. Then I did npm install for all my projects. Then I tried the commands rnpm link and react-native link react-native-sqlite-storage, both of which gave this error:
ERR! It seems something went wrong while linking. Error: spawn UNKNOWN
Please file an issue here: https://github.com/rnpm/rnpm/issues
So now the project won't even build. Any ideas?
the problem is the library is not linked
to link they suggest two ways
with pod (advanced)
with rnpm link (easy) but this command is deprecated
so to link the library you should use the
react-native link react-native-sqlite-storage
this command is equal to rnpm link but not deprecated
if automatic build failing try with manual linking for iOS manually linking ios and android manually linking android
lstat command error is generating on windows due to permission issues or npm version issues.
You can do 2 things to pass this.
1.Open terminal in admin mode .
2.upgrade/degrade npm version
For plugin installation, configure manually
You need change MainApplication.java with:
import org.pgsqlite.SQLitePluginPackage;
and
in getPackages:
new SQLitePluginPackage()

React Native - SQLite configuration error

First off, I tried to search for questions that kind of relates to the problem that I am facing, but alas no luck at all! If this question has been answered before, please do point me to it and sorry for the inconvenience.
Coming as a Cordova developer react-native sounds like a dream coming true but I am still a noob at it and am still learning it. I installed this SQLite plugin and followed every step for android development. But when I try to run the app on a simulator I always get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-sqlite-storage'.
> failed to find Build Tools revision 23.0.1
The configurations that I did:
settings.gradle:
rootProject.name = 'todo'
include ':app'
include ':react-native-sqlite-storage'
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
build.gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
[...]
MainApplication.java:
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new SQLitePluginPackage(this),
new MainReactPackage();
);
Thank you in advance.
there is another "build.gradle" file that you should config!
in your ".../node_modules/react-native-sqlite-storage/src/android/src/build.gradle"
change the build version on that file too!
set it with your build.gradle that already changed!
In your Android studio go to your SDK manager and find SDK tools tab. In there if you check the 'Show Package Details' you will find "Android SDK Build-Tools 23.0.1"
Install that and you are good to go :)

meteor Uncaught ReferenceError: Tracker is not defined

I'm getting the following error - Uncaught ReferenceError: Tracker is not defined
I am running meteor under windows(meteor version 0.8.3).
The code is in my templates js file.
Tracker.autorun(function (c) {
if (MovieTrailers.find().fetch().length == 0)
return;
c.stop();
PlayCurrentTrailer();
});
So far I have tried :
meteor add deps
But that didn't work.
Is tracker available under 0.8.3? or am I missing a package?
tracker is the new name of deps, so replace the occurrence of tracker in your code with deps and you're good to go.
Try to avoid running older versions of Meteor to develop new code, can't you run a VM or use an online service like Nitrous.io for development purpose, as deploying a Meteor app to production in a Windows environment for the moment is not going to happen anytime soon ?

Resources