NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.21k stars 241 forks source link

Path must be a string. Received undefined #805

Closed HenriqueMatias closed 7 years ago

HenriqueMatias commented 7 years ago

Hi guys I'm trying to build my app on android. I'm using windows, but i just receive : Path must be a string. Received undefined my package.json is:

{
  "name": "meu-patrocinio",
  "description": "Meu Patrocinio",
  "version": "1.0.0-rc.3",
  "license": "",
  "readme": "",
  "repository": "",
  "nativescript": {
    "id": "org.nativescript.meupatrocinio",
    "tns-ios": {
      "version": "2.5.0"
    },
    "tns-android": {
      "version": "3.0.0"
    }
  },
  "dependencies": {
    "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/router": "~4.0.0",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.1",
    "email-validator": "1.0.4",
    "faker": "^3.1.0",
    "moment": "^2.17.1",
    "nativescript-angular": "~1.5.0",
    "nativescript-angular-snapshot": "1.5.1-5.5.372.32",
    "nativescript-background-http": "^2.5.1",
    "nativescript-bcryptjs": "^1.0.1",
    "nativescript-camera": "0.0.8",
    "nativescript-cardview": "^1.3.1",
    "nativescript-checkbox": "^1.2.6",
    "nativescript-fancyalert": "^1.1.2",
    "nativescript-geolocation": "0.0.17",
    "nativescript-image-cache-media": "^1.0.6",
    "nativescript-imagecropper": "*",
    "nativescript-imagepicker": "^2.4.1",
    "nativescript-intercom-bridge": "^1.0.0",
    "nativescript-loading-indicator": "^2.2.2",
    "nativescript-local-notifications": "^1.2.1",
    "nativescript-permissions": "^1.2.2",
    "nativescript-photoviewer": "^1.0.0",
    "nativescript-socketio": "*",
    "nativescript-svg": "^1.1.4",
    "nativescript-vibrate": "*",
    "nativescript-web-image-cache": "^4.0.0",
    "redux": "^3.6.0",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.1.0",
    "tns-core-modules": "~2.5.2",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "babel-traverse": "6.21.0",
    "babel-types": "6.21.0",
    "babylon": "6.15.0",
    "filewalker": "0.1.2",
    "lazy": "1.0.11",
    "nativescript-dev-android-snapshot": "0.0.6",
    "nativescript-dev-typescript": "^0.3.5",
    "tslint": "^4.3.1",
    "tslint-eslint-rules": "^3.2.3",
    "tslint-microsoft-contrib": "^4.0.0",
    "typescript": "~2.1.0"
  },
  "scripts": {
    "ns-bundle": "ns-bundle",
    "postinstall": "cp -n app/shared/environment.ts.sample app/shared/environment.ts",
    "start-android-bundle": "npm run ns-bundle --android --start-app",
    "start-ios-bundle": "npm run ns-bundle --ios --start-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  }
}
NickIliev commented 7 years ago

@HenriqueMatias you are mismatching the Android platform version (tns-android 3.0.0.) and the version of your tns-core-modules 2.5.2 along with the used plugins and devDependencies.

As NativeScript 3.0.0 introduced some breaking changes, it is not backward compatible with 2.5.x. So you should either add your Android platform version 2.5.0 or update and migrate the whole project to 3.0.0 (meaning that you will have to set plugin versions compatible with 3.0.0. and also correct any breaking changes that need correction in your code base).

To build your project for 2.5.0 do the following:

rm -rf node_modules 
// make sure that the plugin versions in your package.json are compatible with NativeScript 2.5.x
tns platform remove android
tns platform add android@2.5.0
tns build android

Note that with your current package.json some of the plugin's versions are * meaning that they will install the latest published version which might lead to incompatibility if the latest version is migrate for usage with NativeScript 3.0.0. Use hard versioning for project built for NativeScript 2.5.x and below

If you choose to migrate the whole project to 3.0.0 you will need several things:

HenriqueMatias commented 7 years ago

Hey thanks @NickIliev ! :)

additionally , i had to run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

now its working on ubuntu. But i would like it works on windows

NickIliev commented 7 years ago

@HenriqueMatias can you clarify what is the issue you are hitting on Windows?

NickIliev commented 7 years ago

@HenriqueMatias this error might appear if you do not have the Android SDK installed. Verify that you have installed Android SDK and set the environment variables and let us know if you need further assistance.

rottenoats commented 7 years ago

It would appear that I have my environment variables, and the latest version of tns-android and tns-core-modules installed. I opened Android Studio and updated to the latest sdk. Any ideas why I'm getting this error? (I'm able to run iOS without a problem)

package.json

{
    "description": "NativeScript Application",
    "license": "SEE LICENSE IN <your-license-filename>",
    "readme": "NativeScript Application",
    "repository": "<fill-your-repository-here>",
    "nativescript": {
        "id": "org.nativescript.nsWebsurg",
        "tns-ios": {
            "version": "3.0.1"
        }
    },
    "dependencies": {
        "@angular/animations": "~4.2.3",
        "@angular/common": "~4.2.3",
        "@angular/compiler": "~4.2.3",
        "@angular/core": "~4.2.3",
        "@angular/forms": "~4.2.3",
        "@angular/http": "~4.2.3",
        "@angular/platform-browser": "~4.2.3",
        "@angular/router": "~4.2.3",
        "nativescript-angular": "~3.0.0",
        "nativescript-telerik-ui": "^2.0.1",
        "nativescript-theme-core": "~1.0.2",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~5.4.1",
        "tns-android": "3.0.1",
        "tns-core-modules": "~3.0.0",
        "zone.js": "~0.8.2"
    },
    "devDependencies": {
        "nativescript-dev-sass": "^1.1.1",
        "nativescript-dev-typescript": "~0.4.0",
        "node-sass": "*",
        "typescript": "~2.3.4"
    }
}

.bash_profile

export ANDROID_HOME="${HOME}/Library/Android/sdk"
export PATH="$ANDROID_HOME/tools:$PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"

Error:

The plugin tns-android@3.0.1 is already installed TypeError: Path must be a string. Received undefined # run android

bonlemuel commented 7 years ago

Hi @rugdealer

+1 on this issue. Please help.

dacrystal commented 7 years ago

I ran on the same issue after removing my old android sdk setup that was installed via brew and then install Android Studio instead. (Mac)

Here is a list of most important things I have done to to fix mine.

sdkmanager

Make sure you have the following installed by sdkmanager to resolve tns doctor complaints(versions are important):

Here is my sdkmanager --list:

$ $ANDROID_HOME/tools/bin/sdkmanager --list
Installed packages:
  Path                              | Version      | Description                       | Location                         
  -------                           | -------      | -------                           | -------                          
  build-tools;25.0.3                | 25.0.3       | Android SDK Build-Tools 25.0.3    | build-tools/25.0.3/              
  build-tools;26.0.0                | 26.0.0       | Android SDK Build-Tools 26        | build-tools/26.0.0/              
  emulator                          | 26.0.3       | Android Emulator                  | emulator/                        
  extras;android;m2repository       | 47.0.0       | Android Support Repository        | extras/android/m2repository/     
  extras;google;g...e_play_services | 41           | Google Play services              | extras/google/g..._play_services/
  extras;google;m2repository        | 54           | Google Repository                 | extras/google/m2repository/      
  extras;intel;Ha...ecution_Manager | 6.1.1        | Intel x86 Emulator Accelerator... | extras/intel/Ha...cution_Manager/
  extras;m2reposi...ut-solver;1.0.2 | 1            | Solver for ConstraintLayout 1.0.2 | extras/m2reposi...t-solver/1.0.2/
  extras;m2reposi...nt-layout;1.0.2 | 1            | ConstraintLayout for Android 1... | extras/m2reposi...t-layout/1.0.2/
  ndk-bundle                        | 15.0.4075724 | NDK                               | ndk-bundle/                      
  patcher;v4                        | 1            | SDK Patch Applier v4              | patcher/v4/                      
  platform-tools                    | 26.0.0       | Android SDK Platform-Tools        | platform-tools/                  
  platforms;android-25              | 3            | Android SDK Platform 25           | platforms/android-25/            
  platforms;android-26              | 1            | Android SDK Platform 26           | platforms/android-26/            
  system-images;a...google_apis;x86 | 4            | Google APIs Intel x86 Atom Sys... | system-images/a...oogle_apis/x86/
  tools                             | 26.0.2       | Android SDK Tools                 | tools/                           

package.json (important)

tns-android DOSE NOT belong to dependencies. It should be under nativescript. Somehow the build process fail to move tns-android after adding it as dependencies.

To fix this, remove it from dependencies. Then add from tns platform add android or just tns run android

Path Environment

##    ANDROID    ##
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH