简体   繁体   中英

Ionic run App on Device

im trying to run my Ionic App in my Device using ADB, my device is detected, i added android platform to my Project and everything is fine but when i run

ionic cordova run android --device

I dont get the App on the device here's my console log:

        $  ionic cordova run android --device
Running app-scripts build: --platform android --target cordova
[21:37:05]  build dev started ...
[21:37:05]  clean started ...
[21:37:05]  clean finished in 15 ms
[21:37:05]  copy started ...
[21:37:06]  deeplinks started ...
[21:37:07]  deeplinks finished in 188 ms
[21:37:07]  transpile started ...
[21:37:15]  transpile finished in 8.39 s
[21:37:15]  preprocess started ...
[21:37:15]  preprocess finished in less than 1 ms
[21:37:15]  webpack started ...
[21:37:32]  webpack finished in 16.57 s
[21:37:18]  copy finished in 12.81 s
[21:37:32]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[21:37:33]  sass finished in 1.53 s
[21:37:33]  postprocess started ...
[21:37:33]  postprocess finished in 32 ms
[21:37:33]  lint started ...
[21:37:33]  build dev finished in 27.89 s
> cordova run android --device
Unable to load PlatformApi from platform. Error: Cannot find module 'C:\Users\Win 7\Desktop\pfe\pfe4\platforms\android\cordova\Api.js'

(node:4880) UnhandledPromiseRejectionWarning: Error: Unhandled "error" event. (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.)
at EventEmitter.emit (events.js:186:19)
at EventEmitter.module.exports.emit (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\events.js:71:17)
at Object.getPlatformApiFunction (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\util.js:499:20)
at Object.getPlatformApi (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\platforms\platforms.js:55:25)
at C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:54:38
at Array.map (<anonymous>)
at C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:52:47
at _fulfilled (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\Win 7\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
(node:4880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4880) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/validation/validation.ts, line: 2
        All imports are unused.

   L1:  import { Component } from '@angular/core';
   L2:  import { HomePage } from './../home/home';
   L3:  import { IonicPage, NavController, NavParams } from 'ionic-angular';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signup/signup.ts, line: 171
        'tocheck' is declared but never used.

 L170:  checkIfExistUsername(){
 L171:    var tocheck;
 L172:    var check = this.authServiceProvider.getData("user/"+this.userData.username);

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signup/signup.ts, line: 182
        'tocheck' is declared but never used.

 L181:  checkIfExistEmail(){
 L182:    var tocheck;
 L183:    var check = this.authServiceProvider.getData("userbymail/" + this.userData.email);

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signup/signup.ts, line: 1
        All imports are unused.

   L1:  import { HomePage } from './../home/home';
   L2:  import { Component } from '@angular/core';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signup/signup.ts, line: 3
        'NavParams' is declared but never used.

   L2:  import { Component } from '@angular/core';
   L3:  import { IonicPage, NavController, NavParams } from 'ionic-angular';
   L4:  import { AuthServiceProvider } from '../../providers/auth-service/auth-service';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signin/signin.ts, line: 1
        All imports are unused.

   L1:  import { ValidationPage } from '../validation/validation';
   L2:  import { Component } from '@angular/core';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/signin/signin.ts, line: 5
        All imports are unused.

   L4:  import { SignupPage } from '../signup/signup';
   L5:  import { HttpClient } from '@angular/common/http';
   L6:  import { Observable } from 'rxjs/Observable';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/home/home.ts, line: 1
        All imports are unused.

   L1:  import { ValidationPage } from '../validation/validation';
   L2:  import { Component } from '@angular/core';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/home/home.ts, line: 6
        All imports are unused.

   L5:  import { SigninPage } from '../signin/signin';
   L6:  import { HttpClient } from '@angular/common/http';
   L7:  import { Observable } from 'rxjs/Observable';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/home/home.ts, line: 7
        All imports are unused.

   L6:  import { HttpClient } from '@angular/common/http';
   L7:  import { Observable } from 'rxjs/Observable';
   L8:  import { AuthServiceProvider } from '../../providers/auth-service/auth-service';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/home/home.ts, line: 8
        All imports are unused.

   L7:  import { Observable } from 'rxjs/Observable';
   L8:  import { AuthServiceProvider } from '../../providers/auth-service/auth-service';
   L9:  import { AlertController } from 'ionic-angular';

[21:37:37]  tslint: C:/Users/Win 7/Desktop/pfe/pfe4/src/pages/home/home.ts, line: 9
        All imports are unused.

   L8:  import { AuthServiceProvider } from '../../providers/auth-service/auth-service';
   L9:  import { AlertController } from 'ionic-angular';
  L10:  import CryptoJS from 'crypto-js';


[21:37:37]  lint finished in 4.04 s

[OK] Your app has been deployed.
 Did you know you can live-reload changes from your app with --livereload?

First, you need to clean your code. Because All 'imports are unused.'. Remove all imports that are not used in your code.
To run you Ionic Application on Mobile device follow these steps:

  • Run this command

    $ adb devices

If, your device is connected, you'll get something like this as output:

List of devices attached 
02003106B2303888    device
  • Now, launch your application with:

    $ ionic cordova run android --target=02003106B2303888

我错过了Android 7 SDK,我安装了它并成功了!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM