NativeScript tns run android --device/emulator doesn't work - nativescript

Im new to native script and ive been to trying to test on device or emulator. thats what im getting.
C:\Users\Muzi J\Documents\tns\HelloWorld>tns run android --device 4TE7N17106003969
Copying template files...
- Installing tns-androidInstalling tns-android
C:\Users\Muzi J\Documents\tns\HelloWorld
`-- tns-android#2.5.0
Exception: The plugin tns-android#2.5.0 is already installed

There are a couple things you can try:
Delete your platforms folder and remove the line item inside the main package.json that has "android": "2.5.x" Then do a tns platform add android
Try moving your code into a folder without a space in it. I've seen some issues recently in the issues where spaces in the name were causing build issues.

Related

Can't find React native project on iOS Simulator or Xcode project

I have deleted my project on Xcode may it be .xcworkspace or .xcodeproj.
Because of that, I had to delete IOS and android folders while downgrading, updating and re-upgrading my react version to re-install IOS and android folders.
Thanks to that the emulator is working but unfortunately the project isn't present in the emulator and is still absent with Xcode. One thing to point out is that the simulator only appears when ran in the integrated terminal and nor in general terminal after cd-ing in the project folder.
Can anyone please help re-integrating the project in the emulator and on Xcode, please.
Here is the error when the emulator is running in a general terminal:
Here is the error when the emulator is running in a general terminal:
error Command failed: xcrun instruments -s
xcrun: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk' (errno=No such file or directory)
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
Here is the error for building the project within emulator when ran from VS code integrated terminal:
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening project.xcodeproj
The process you need to follow is so similar to renaming a react native app. Basically you just need to run react-native upgrade in your root project directory. For further info you can check another question here. The instructions below explains how to create another react native project based on a copied one with a new name.
First copy the directory which your to-be-name-changed application exists. And go to your newly cloned directory.
Change the name at index.ios/android.js file which is given as a parameter to AppRegistry.
Change the name and version accordingly on package.json
Delete /ios and /android folders which are remaining from your older app.
Run $react-native upgrade to generate /ios and /android folders again.
Run $react-native link for any native dependency.
Finally run $react-native run-ios or anything you want.
Courtesy of
https://stackoverflow.com/questions/42506068/how-can-i-regenerate-ios-folder-in-react-native-project

Error ENOENT: no such file or directory, scandir 'PATH_PORJECT\platforms\android\app\src\main\res'

I have an error I have a when running tns platform add android command.
I can run other apps (new apps) but no my current and all happens after I install codeworks_android it change the path for the SDK then I reinstall native-script but I'm not able to add the Android platform.
CODEWORKS
error ENOENT: no such file or directory, scandir 'PATH_PORJECT\platforms\android\app\src\main\res'
Adding the platform would help (For both Android and iOS),
tns platform add ios
tns platform add android
More explanation in Doc here
If the platform already exists(you can check inside the platforms folder), you can try remove/clean before adding again,
tns platform remove android
tns platform clean android
If you are using the Nativescript seed project (like NS advanced seed), make sure you are in mobile app's root folder(typically nativesctript inside the projects root folder) when you add or remove the platforms.
Adding the solution as an answer here with little more information (instead of an update in the comment) so others can get it easily.
These commands solved my problem
npm i
ns run android

nativescript 2.5 blank template error

I have just updated to NativeScript 2.5
I have created a new blank project using tns-template-blank:
$ tns create BlankProject --template tns-template-blank
...... Project BlankProject was successfully created.
When I try to run it, I get an error:
$ cd BlankProject $ tns run ios --emulator
We have failed to check if we need to add a compatability
LaunchScreen.xib due to: Error: ENOENT: no such file or directory,
open
'/Users/joseanquiles/MyProjects/Nativescript/BlankProject/app/App_Resources/iOS/Info.plist'
ENOENT: no such file or directory, scandir
'/Users/joseanquiles/MyProjects/Nativescript/BlankProject/platforms/ios/BlankProject/Resources'
However, if I create a new project using default template (without --template option), it run ok in iOS emulator.
Before, with NativeScript 2.4.2, it run perfectly, using blank template.
Is there a problem with blank template and 2.5 ?
Thank you in advance.
I had the same problem (for an iOS build) using both the tns-template-tab-navigation and the tns-template-master-detail and i noticed that a folder (and its contents) were missing from the app folder... the missing folder is called App_Resources.....
To fix the problem I just found a previous project that i had built with the default template (I think...) and copied the App_Resources folder across into the failing app folder.
My guess is that only a couple of the templates actually build the App_resources folder correctly but once you have copied the folder across from a successful build it 'should' work OK
Cheers
Ian

'hello/Hello.h' file not found - Trying to build/run iOS gomobile Hello app

I am building the gomobile Hello example app, but am running into the following problem: When trying to build and run the app after opening it in Xcode (7.1), I get the error 'hello/Hello.h' file not found'
From what I can tell, Hello.h is in fact in the hello folder of the native directory.
Following this discussion on Github, it seems like this is due to a recent change in the way Xcode 7 updates paths for the headers.
The proposed solution is to check Copy items if needed when importing the framework:
I can confirm that this fixes the issue. But note that you would then need to re-import the framework every time you make changes and build the go code.

Grunt, Cordova & Windows Phone

I am developing an app for multiple platforms using Cordova. Grunt is used as a build tool. I use it to copy my source code to the right folder for each platform so I can develop them independently.
This works fine with Android using the scripts that are provided by Cordova. However, I have no idea if or how it is possible to automate the WP build process. I'm looking for two things:
Add all files in the www directory to the VS project (it does not include files that are not added to the project, which is sad).
Build, install and run the app in the emulator. I used adb & Grunt's exec for Android which was really simple, is there something similar for WP?
If you look in a cordova windows phone project there is a directory called 'cordova' which contains scripts to do all of this.
There should be scripts to build and run your project.
The run script can pretty much do it all. You can call it like :
run --device --release
or
run --emulator --debug
or just
run
A recent commit now makes it possible to use www\** in the .csproj file, which solved my first issue.

Resources