我试图在我的设备中使用ADB运行我的Ionic App,检测到我的设备,我将android平台添加到我的项目中,一切都很好,但是当我运行时
ionic cordova run android --device
我没有在设备上获取应用程序,这是我的控制台日志:
$ 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?
答案 0 :(得分:0)
首先,您需要清理代码。因为所有'进口都未使用。'。删除代码中未使用的所有导入。
要在移动设备上运行Ionic Application,请按照以下步骤操作:
运行此命令
$ adb devices
如果您的设备已连接,您将获得类似输出的内容:
List of devices attached
02003106B2303888 device
现在,使用以下命令启动您的应用程序:
$ ionic cordova运行android --target = 02003106B2303888
答案 1 :(得分:0)
我错过了Android 7 SDK,我安装了它并且有效!