我正在使用Ionic为Android构建,我总是收到此错误:
我来自ionic info
:
毫无疑问,我浏览了整个互联网寻找解决方案,但我没有成功 我看过并阅读了以下内容:
我还观察到,与其他人相比,我有这个独特的错误:
Security context: 000001F502E3FA99 <JS Object>
1: createLiteral [..]
2: typeToTypeNodeHelper(aka typeToTypeNodeHelper) [..]
我已经被困了2天以上,我真的需要帮助和指导。
这是我的package.json内容:
{
"name": "project",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
"@angular/compiler-cli": "5.2.10",
"@angular/core": "5.2.10",
"@angular/forms": "5.2.10",
"@angular/http": "5.2.10",
"@angular/platform-browser": "5.2.10",
"@angular/platform-browser-dynamic": "5.2.10",
"@ionic-native/camera": "^4.5.2",
"@ionic-native/core": "4.4.0",
"@ionic-native/file": "^4.7.0",
"@ionic-native/file-chooser": "^4.7.0",
"@ionic-native/file-path": "^4.7.0",
"@ionic-native/geolocation": "^4.7.0",
"@ionic-native/onesignal": "^4.5.2",
"@ionic-native/splash-screen": "4.4.0",
"@ionic-native/status-bar": "4.4.0",
"@ionic-native/twitter-connect": "^4.5.2",
"@ionic/storage": "2.1.3",
"angularfire2": "^5.0.0-rc.6",
"cordova-android": "^7.0.0",
"cordova-browser": "~5.0.3",
"cordova-ios": "4.5.4",
"cordova-plugin-camera": "^2.4.1",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-filechooser": "^1.0.1",
"cordova-plugin-filepath": "^1.3.0",
"cordova-plugin-geolocation": "^4.0.1",
"cordova-plugin-inappbrowser": "^2.0.2",
"cordova-plugin-ionic-webview": "^1.2.0",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"firebase": "^4.12.1",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"jssha": "^1.6.2",
"moment": "^2.20.1",
"onesignal-cordova-plugin": "^2.2.5",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/cli": "^1.7.3",
"@angular-devkit/build-optimizer": "^0.5.7",
"@ionic/app-scripts": "^3.1.8",
"@types/jssha": "0.0.29",
"typescript": "^2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-inappbrowser": {},
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-splashscreen": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-filechooser": {},
"cordova-plugin-camera": {
"CAMERA_USAGE_DESCRIPTION": " ",
"PHOTOLIBRARY_USAGE_DESCRIPTION": " "
},
"twitter-connect-plugin": {
"FABRIC_KEY": "XXXXXXXXXX",
"TWITTER_KEY": "YYYYYYYYY",
"TWITTER_SECRET": "ZZZZZZZZZZZZZZZ"
},
"cordova-plugin-statusbar": {},
"cordova-plugin-filepath": {},
"cordova-plugin-file": {},
"cordova-plugin-geolocation": {}
},
"platforms": [
"ios",
"browser",
"android"
]
},
"main": "index.js",
"license": "ISC"
}
编辑: 我根据@Suraj Rao的建议更新了我的npm,我的版本是6.0.0作为当前版本,然后我再次尝试构建,我得到了这个new related error
答案 0 :(得分:1)
我观察到一些问题是依赖性不兼容(某些依赖项需要特定版本才能工作),但最常见的是 - prod in ionic cordova build syntax。这个构建选项是排序的噩梦。我停留了7个多小时没有终止。如果没有此选项,则意味着在需要AOT时使用角度编译器构建。经过大量浏览和阅读后,我能够在没有--prod的情况下构建,但仍然通过此命令使用AOT 离子cordova运行android --aot true --environmen t prod --output-hashing all --sourcemaps false --extract-css true --named-chunks false --build-optimizer true 检查here。虽然不确定它是否正确,但我得到了我想要的结果。
答案 1 :(得分:0)
您可以尝试这些可能对您有帮助的步骤!
首先尝试npm install
并按照以下方法之一...
将此添加到package.json脚本
"ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",
运行命令:
npm run ionic:build --prod
运行命令:
cordova build android --release
cordova build ios --release
或者
修改:
node_modules/.bin/ionic-app-scripts.cmd
添加:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=4096 "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
)
然后运行ionic build android --prod
<强> 更新 强>
我不确定到底出了什么问题,但我可以理解存在超出限制的巨大文件或内存使用量。
试试这个,
node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192 --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192 --prod --aot
希望这能帮到你!