![](/img/trans.png)
[英]Running Gradle Build - Failed When i tried to run ionic capacitor run android -l --external
[英]Android white screen when running ionic capacitor run with SSL
我正在嘗試運行一個簡單的測試,嘗試將離子和電容器添加到已經存在的 angular 項目中。 我已經設法讓它工作並正常運行,但是當我將 SSL 命令添加到 CLI 以便服務器使用 HTTPS 運行時,應用程序不再加載,我只能看到一個空白屏幕。 此外,如果我從瀏覽器手動訪問 URL 一切都會正確加載。 是不是在 Android Studio 或離子/電容器文件中配置錯誤? 我已經嘗試了不同的配置和不同的模擬設備和不同的 Android 版本,但是沒有用,我無法讓它工作。 如果有人可以幫助我,我當然會很感激......
運行ionic capacitor run android --livereload --external
https://i.stack.imgur.com/ljfUT.png
https://i.stack.imgur.com/8LxNV.png
當我將 --ssl 標志添加到 CLI ionic capacitor run android --livereload --external --ssl
https://i.stack.imgur.com/fS0jV.png
https://i.stack.imgur.com/D3sLL.png
https://i.stack.imgur.com/3v5Bx.png
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'io.ionic.starter',
appName: 'iotest',
webDir: './android/www',
bundledWebRuntime: false
};
export default config;
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"cli": {
"defaultCollection": "@ionic/angular-toolkit"
},
"schematics": {
"@ionic/angular-toolkit:component": {
"styleext": "scss"
},
"@ionic/angular-toolkit:page": {
"styleext": "scss"
}
},
"projects": {
"iotest": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "./android/www",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets",
{
"glob": "**/*.svg",
"input": "./node_modules/ionicicons/dist/ionicicons/svg",
"output": "./svg"
}
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "iotest:build:production"
},
"development": {
"browserTarget": "iotest:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "iotest:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
}
}
},
"defaultProject": "iotest"
}
{
"defaultProject": "iotest",
"projects": {
"iotest": {
"name": "iotest",
"integrations": {
"capacitor": {}
},
"type": "angular"
}
}
}
Angular CLI:12.1.4
節點:16.14.0(不支持)
Package 經理:npm 8.3.1
操作系統:win32 x64
Angular:12.1.5
...動畫,通用,編譯器,編譯器-cli,核心,forms
... 平台瀏覽器、平台瀏覽器動態、路由器
Package版本
-------------------------------------------------- --------
@angular-devkit/架構師 0.1201.4
@angular-devkit/build-angular 12.1.4
@angular-devkit/核心 12.1.4
@angular-devkit/原理圖 12.1.4
@角/cli 12.1.4
@原理圖/角度 12.1.4
rxjs 6.6.7
typescript 4.3.5
警告:Angular 不支持當前版本的 Node (16.14.0)。
版本 8.3.1
我的目標是讓它與 SSL 一起運行,因為將來我需要將它應用於需要與 HTTPS 一起運行的應用程序
從電容器.config.ts 進行如下更改:
{
...
server: {
url: 'https://your-local-ip:8100' // like: 192.168.1.66:8100
androidScheme: 'https',
clearText: true // just for test
}
...
}
然后打開兩個終端並運行以下命令:
ionic cap run android -l --external --ssl
從第二個終端運行:
ionic serve 0.0.0.0 --ssl
畢竟,如果您仍然看到空白頁面,請從移動設備和 go 到 https://your-host-ip:8100 打開瀏覽器,然后確保 Z572D4E421E5E6B9BC112D815E8A0271 是可信的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.