0

我正在通过以下步骤在本地生成 apk 构建:

  1. 删除任何以前的输出:rm -rf platforms/
  2. 在本地生成密钥库并注意其存储位置:
    keytool -genkeypair -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
    
  3. 使用上述密钥库/密钥密码/别名构建发布版本: tns build android --release --key-store-path [location-of-.keystore] --key-store-password [keystore-pass] --key-store-alias [alias-name] --key-store-alias-password [alias-pass]
  4. 尝试在 android 设备上安装并得到“解析包时出现问题”。

这是我的 package.json 文件:

{
  "nativescript": {
    "id": "<ID>",
    "tns-ios": {
      "version": "6.5.2"
    },
    "tns-android": {
      "version": "6.5.2"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "scripts": {
    "postinstall": "node postinstall.js",
    "lint": "eslint -c .eslintrc.js \"src/**/*.ts\"",
    "fix-lint": "eslint --fix --no-eslintrc -c .eslintrc.autofix.js \"src/**/*.ts\"",
    "test:android": "tns test android",
    "test:ios": "tns test ios"
  },
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@nativescript/theme": "^2.3.3",
    "@nstudio/nativescript-checkbox": "^1.0.0",
    "@nstudio/nativescript-loading-indicator": "^3.0.3",
    "@nstudio/nativescript-tracking-transparency": "^1.0.0",
    "@types/node": "^13.9.1",
    "email-validator": "^2.0.4",
    "geolib": "^3.3.1",
    "guid-typescript": "^1.0.9",
    "moment": "^2.24.0",
    "nativescript-angular": "^8.21.0",
    "nativescript-appversion": "^1.4.4",
    "nativescript-datetimepicker": "^1.2.2",
    "nativescript-drop-down": "^5.0.6",
    "nativescript-facebook": "^4.2.1",
    "nativescript-fancyalert": "^3.0.9",
    "nativescript-feedback": "^1.3.12",
    "nativescript-geolocation": "^5.1.0",
    "nativescript-gif": "^4.0.6",
    "nativescript-google-maps-sdk": "^2.9.1",
    "nativescript-google-places-autocomplete": "^1.0.3",
    "nativescript-iqkeyboardmanager": "^1.5.1",
    "nativescript-local-notifications": "^4.2.1",
    "nativescript-masked-text-field": "^4.0.3",
    "nativescript-mediafilepicker": "^3.0.1",
    "nativescript-menu": "^1.1.3",
    "nativescript-ngx-fonticon": "^5.0.2",
    "nativescript-ngx-shadow": "^6.5.0",
    "nativescript-plugin-appsflyer": "6.0.0",
    "nativescript-plugin-firebase": "^10.5.0",
    "nativescript-sentry": "^1.9.1",
    "nativescript-ui-dataform": "^6.0.0",
    "nativescript-ui-listview": "^8.0.1",
    "nativescript-ui-sidedrawer": "~8.0.0",
    "nativescript-unit-test-runner": "^0.7.0",
    "ngx-moment": "^3.5.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "^6.4.2",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular-eslint/eslint-plugin": "0.0.1-alpha.32",
    "@angular-eslint/eslint-plugin-template": "0.0.1-alpha.32",
    "@angular/compiler-cli": "^8.2.14",
    "@nativescript/schematics": "^1.0.0",
    "@ngtools/webpack": "^8.2.2",
    "@schematics/angular": "^8.3.25",
    "@types/chai": "^4.2.11",
    "@types/karma-chai": "0.1.2",
    "@types/mocha": "7.0.2",
    "@types/sinon": "^9.0.4",
    "@typescript-eslint/eslint-plugin": "^3.6.1",
    "@typescript-eslint/eslint-plugin-tslint": "^3.6.1",
    "@typescript-eslint/parser": "^3.6.1",
    "chai": "4.2.0",
    "codelyzer": "^5.2.1",
    "eslint": "^7.4.0",
    "eslint-config-prettier": "^6.10.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsdoc": "^29.2.0",
    "eslint-plugin-prefer-arrow": "^1.2.1",
    "eslint-plugin-prettier": "^3.1.2",
    "istanbul-instrumenter-loader": "^3.0.1",
    "json": "^9.0.6",
    "karma": "5.1.0",
    "karma-chai": "0.1.0",
    "karma-coverage": "^2.0.3",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-mocha": "1.3.0",
    "karma-nativescript-launcher": "0.4.0",
    "karma-sinon": "^1.0.5",
    "karma-sonarqube-unit-reporter": "0.0.21",
    "karma-spec-reporter": "0.0.32",
    "karma-webpack": "3.0.5",
    "mocha": "7.1.0",
    "nativescript-dev-webpack": "^1.5.1",
    "node-sass": "^4.7.1",
    "prettier": "^1.19.1",
    "sinon": "^9.0.2",
    "tns-android": "6.5.2",
    "tns-ios": "6.5.2",
    "tns-platform-declarations": "^6.4.2",
    "tslint": "^6.1.0",
    "tslint-config-prettier": "^1.18.0",
    "tslint-plugin-prettier": "^2.2.0",
    "typescript": "~3.5.3"
  },
  "readme": "NativeScript Application"
}

我试图用不同版本的java构建。最后一次尝试是

openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode)

这是我的 tns 版本:

tns --version 6.7.4

我已经使用完全相同的方法成功构建,所以不确定可能发生了什么变化。Fwiw 我也尝试了这种确切的方法,但是使用的是.jks密钥库文件类型而不是.keystore.

另外,tns医生看起来不错。这显然是 NS 的过时版本,但看起来还不错:

✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 12.5.1 satisfies minimum required version 10.
✔ Getting NativeScript components versions information...
⚠ Update available for component nativescript. Your current version is 6.7.4 and the latest available version is 8.0.2.
⚠ Update available for component tns-core-modules. Your current version is 6.5.0 and the latest available version is 6.5.27.
⚠ Update available for component tns-android. Your current version is 6.5.2 and the latest available version is 6.5.3.
⚠ Update available for component tns-ios. Your current version is 6.5.2 and the latest available version is 6.5.4.

其他需要注意的事项:代码在模拟器上的调试模式下运行良好,通过 USB 直接在同一设备上构建和运行良好,所讨论的设备是 Galaxy S9/Android 10。

任何见解将不胜感激。提前致谢!

4

0 回答 0