NativeScript Angular project 'tns run android' gives errors - android

I created a project using the following command:
ng new -c=#nativescript/schematics project-name --shared
When I run tns run android, I get the following errors:
platforms/android/app/build/intermediates/merged_assets/debug/mergeDebugAssets/out/app/tns_modules/zone.js/lib/zone-spec/long-stack-trace.ts(25,10): error TS2393: Duplicate function implementation.
platforms/android/app/build/intermediates/merged_assets/debug/mergeDebugAssets/out/app/tns_modules/zone.js/lib/zone.ts(632,6): error TS2300: Duplicate identifier 'AmbientZone'.
platforms/android/app/src/main/assets/app/tns_modules/rxjs/src/operator/catch.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/operator/catch'.
These are just sample errors. There are so many of these kind.
I tried;
Removing node_modules folder and run npm install
Removing platforms/android folder
Updating NativeScript(5.1.0) and Angular CLI()
Removing /users/username/.gradle folder and let it reinstall
Reinstalling Nodejs
Installing rxjs-compat which only solves rxjs-compat related errors
Nothing worked so far.
ng --version
Angular CLI: 7.2.1+
Angular: 7.1.4
#angular-devkit/architect 0.12.1 (cli-only)
#angular-devkit/core 7.0.7
#angular-devkit/schematics 7.0.7
#ngtools/webpack 7.1.4
#schematics/angular 7.0.7
#schematics/update 0.12.1 (cli-only)
rxjs 6.3.3
typescript 3.1.6
webpack 4.27.1
tns --version
5.1.0

Please see the issue here
Basically, remove the tns_modules folder from platforms/android/app/build/intermediates/merged_assets/debug/mergeDebugAssets/out/app/tns_modules/
It is apparently caused by npm link command I used somewhere.

Related

Error in nativescript-permissions when running android app

My app was running fine and now it is showing me an error which i tried to figure out until now.
ERROR in ../node_modules/nativescript-permissions/permissions.js
Module not found: Error: Can't resolve '#master.technology/permissions' in '/Users/abdull/Desktop/my-app/node_modules/nativescript-permissions'
# ../node_modules/nativescript-permissions/permissions.js 13:17-58
# ../node_modules/#nativescript/imagepicker/index.js
# ./app/shared/image-helper.ts
# ./app/app.module.ts
# ./main.ts
After searching i figured out that i have a plugin "#nativescript/imagepicker": "^1.0.5" which requires "nativescript-permissions": "~1.3.0" in package-lock.json
Migrating from NativeScript 7 to NativeScript 8 fixed the issue for me. To migrate see the link https://v6.docs.nativescript.org/angular/releases/upgrade-instructions
$ tns migrate
After migration, when running the app it might say thar zone.js not found. For that the fix is available at:
https://github.com/manfredsteyer/ngx-build-plus/issues/4
Add
import 'zone.js' in main.ts

Errors when building : no source map reference + remove sentry-cordova exited with exit code 1

I'm trying to build my ionic app for android and most users have a white screen after the splashscreen. I've past the past week to try to determine where it could come but got no idea... So I'm trying to get rid of all the errors I have when building. (it still succed to build with the errors and worked on almost half phones).
First one is here :
Building for Android...
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd plugin remove sentry-cordova exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
> cordova.cmd plugin remove sentry-cordova Sentry: running before_plugin_rm - set SENTRY_SKIP_WIZARD=true to skip this angular.json build.json build_android.sh build-extras.gradle CertificateSigningRequest.certSigningRequest
...
tslint.json www Uninstalling sentry-cordova from android Subproject Path: CordovaLib Subproject Path: app Uninstalling sentry-cordova from browser js-module uninstall called : plugins\sentry-cordova\dist\js\sentry-cordova.bundle.js Uninstalling sentry-cordova from ios Removing "sentry-cordova" Removing sentry-cordova from package.json doc.find is not a function
Second one is after, there is multiples lines like this :
- warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/1-es5.1922
I'm pretty sure I miss some informations. Don't hesitate to ask if necessary but I'm sure I forget to do something, but i'm kinda desperate now...
EDIT : Here is the begining of the script I'm using for build :
echo "Building for Android..."
#npm run android:build:prod
sentryRemove=$(ionic cordova plugin remove sentry-cordova)
echo $sentryRemove
sentryAdd=$(cordova plugin add sentry-cordova)
echo $sentryAdd
echo "successfully added the sentry. \n Performing build now."
appBuildOut=$(ionic cordova build android --prod --release --source-map)
echo $appBuildOut
BUILD_MESSAGE='BUILD SUCCESSFUL'
Thanks for your help
The first question is why are you running a plugin remove command when building your app, if I understand correctly. I would check what is calling this command because the script that is erroring before_plugin_rm should only be called when the plugin is being removed.
To get this script to just work, try running with the environment variable SENTRY_SKIP_WIZARD=true and see if the build works. I don't think the reason for the white screen is related to Sentry as the step that is failing looks to be related to source map uploading.

Ionic 2: cordova run android Error (Unmatched closing tag)

When I run cordova run android I see the following error:
Failed to install 'ionic-plugin-keyboard':Error: Unmatched closing tag: widget
Line: 37
Column: 9
Char: >
at error (/platforms/android/cordova/node_modules/sax/lib/sax.js:347:8)
at strictFail (/platforms/android/cordova/node_modules/sax/lib/sax.js:364:22)
at closeTag (/platforms/android/cordova/node_modules/sax/lib/sax.js:529:5)
at Object.write (/platforms/android/cordova/node_modules/sax/lib/sax.js:948:29)
at XMLParser.feed (/platforms/android/cordova/node_modules/elementtree/lib/parsers/sax.js:48:15)
at ElementTree.parse (/platforms/android/cordova/node_modules/elementtree/lib/elementtree.js:271:10)
at Object.exports.XML (/platforms/android/cordova/node_modules/elementtree/lib/elementtree.js:606:13)
at Object.module.exports.parseElementtreeSync (/platforms/android/cordova/node_modules/cordova-common/src/util/xml-helpers.js:123:38)
at ConfigFile_load [as load] (/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigFile.js:70:33)
at new ConfigFile (/platforms/android/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigFile.js:47:10)
Is there any clue on where to look for the error? I checked the config.xml - it looks fine.
So I erased and recreated the project with the latest ionic2 cli now and it seems to work. I just had one error complaining about the config.xml now, which could be solved by deleting the spaces after the </widget>

Cordova - module org.apache.cordova.file.File not found

I am developing apps with Cordova.
I have build an app and when calling this in cli cordova run android --device
it's deploying my app on the device. While debugging on chrome I get:
module org.apache.cordova.file.File not found
Why is that ?
In my config.xml file I have the following:
<plugin name="cordova-plugin-file" version="3.0.0" />
and the plugin is located in cordova\platforms\android\platform_www\plugins
The cordova version is 4.1.1.
What is the difference in these below ?
org.apache.cordova.file.File
org.apache.cordova.file
Consolelogs
xxxx.$application::launch()
file:///android_asset/www/resources/ext-watermark/fonts/ext-watermark.woff?n6lnws Failed to load resource: the server responded with a status of 404 (Not Found)
file:///android_asset/www/resources/images/favicon.ico Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///android_asset/www/resources/ext-watermark/fonts/ext-watermark.ttf?n6lnws Failed to load resource: the server responded with a status of 404 (Not Found)
app.js:1 ::::Cordova DeviceReady::::
app.js:1 Require: org.apache.cordova.inappbrowser.inappbrowser
app.js:1 Require: org.apache.cordova.file.File
cordova.js:59 Uncaught module org.apache.cordova.file.File not found
For me this issue was arising because of dependent plug-in i.e. org.apache.cordova.media-capture
If you have media-capture plugin installed, you would see inside org.apache.cordova.media-capture.MediaFile.js file there is the file dependent code
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
File = require('org.apache.cordova.file.File'),
CaptureError = require('./CaptureError');
Solution:
I have removed the media-capture plugin for now and looking for an update which doesn't ask for old cordova file plugin API.
cordova plugin rm org.apache.cordova.media-capture
I understand that it wouldn't solve your problem completely, but you should be good to go ahead.
Thanks.
I had the same problem. I saw that although I added a newer version of cordova-plugin-file Cordova still used an older version. Removing /platforms and rerunning cordova platform add android did the trick

Issue with phonegap local build for android

I am trying to build my phonegap app locally and am incountering the following error
[phonegap] adding the Android platform...
Error: Invalid attribute name Line: 0 Column: 36 Char: ?
at error (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/node_modules/sax/lib/sax.js:347:8)
at strictFail (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/node_modules/sax/lib/sax.js:364:22)
at Object.write (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/node_modules/sax/lib/sax.js:876:16)
at XMLParser.feed (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/lib/parsers/sax.js:48:15)
at ElementTree.parse (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/lib/elementtree.js:263:10)
at Object.exports.XML (/usr/lib/node_modules/phonegap/node_modules/cordova/node_modules/elementtree/lib/elementtree.js:593:13)
at Object.module.exports.parseElementtreeSync (/usr/lib/node_modules/phonegap/node_modules/cordova/src/xml-helpers.js:111:38)
at Object.config_parser (/usr/lib/node_modules/phonegap/node_modules/cordova/src/config_parser.js:25:20)
at Object.platform (/usr/lib/node_modules/phonegap/node_modules/cordova/src/platform.js:65:15)
at LocalBuildCommand.module.exports.addPlatform (/usr/lib/node_modules/phonegap/lib/phonegap/local.build.js:153:13)
I am using phonegap 3.0.0
I might be a little late but I just had this problem and solved it.
I just deleted the android folder in 'platforms' and reran
phonegap run android
you can also do phonegap add android if you don't want to run it.
Make sure to back up your xml manifests if you made any changes.
The right way is:
1) $ phonegap platform rm android
2) $ phonegap plaftorm add android
3) $ phonegap build android
It is also recommended to do this when you add or remove plugin.

Categories

Resources