gpt4 book ai didi

java - ionic 3 : UnhandledPromiseRejectionWarning when generating APK File

转载 作者:行者123 更新时间:2023-11-30 10:18:30 25 4
gpt4 key购买 nike

我在生成 apk 文件时遇到问题。我收到以下错误。

命令: ionic Cordova 构建安卓

输出:

> cordova build android
Android Studio project detected

ANDROID_HOME=C:\Users\****\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk-9.0.4
(node:17504) UnhandledPromiseRejectionWarning: Unhandled promise rejection (reje
ction id: 1): CordovaError: Requirements check failed for JDK 1.8 or greater
(node:17504) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate th
e Node.js process with a non-zero exit code.

[13:47:49] lint 在 8.47 秒内完成

这是我的rest文件rest.ts的内容

    import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';

@Injectable()
export class RestProvider {

private baseUrl = 'http://localhost/project/web/rest/mobile/v1/';
private nomsvillesUrl = this.baseUrl + 'ville/nomsvilles/1';

constructor(public http: HttpClient) {
console.log('Hello RestProvider Provider');
}

getNomvilles(): Observable<string[]> {
return this.http.get(this.nomsvillesUrl)
.map(this.extractData)
.catch(this.handleError);
}

private extractData(res: Response) {
let body = res;
return body || { };
}

private handleError (error: Response | any) {
let errMsg: string;
if (error instanceof Response) {
const err = error || '';
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error(errMsg);
return Observable.throw(errMsg);
}

}

这是我的主类main.ts的内容

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { RestProvider } from '../../providers/rest/rest';

@Component({
selector: 'page-main',
templateUrl: 'main.html',
})
export class MainPage {

villes: string[]
errorMessage: string

constructor(public navCtrl: NavController, public navParams: NavParams, public rest: RestProvider) {
}

ionViewDidLoad() {
this.getVilles();
}

getVilles() {
this.rest.getNomvilles().subscribe(
villes => this.villes = villes,
error => this.errorMessage = <any>error
);
}

}

请帮帮我!我想知道如何处理 Promise 以防止 promise 被拒绝。

谢谢。

最佳答案

该错误与您的代码无关。它需要jdk 1.8 或更高版本你可以从这个link 下载它.但是首先卸载你正在使用的jdk 1.9,因为它与android不兼容。

然后创建环境变量JAVA_HOME=C:\path\to\jdk\bin

关于java - ionic 3 : UnhandledPromiseRejectionWarning when generating APK File,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49201902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com