NativeScript +角度应用程序在启动时崩溃(android 11 - API 30)

发布于 2025-01-09 03:12:42 字数 2512 浏览 2 评论 0原文

我有一个 NativeScript + Angular 的应用程序,当我在 App_Resources\Android\app.gradle 上将 targetSdkVersion 从 29 到 30(根据 Google 的需要)时,应用程序在启动时崩溃并没有显示任何内容,只是自行关闭。我尝试了很多方法来修复,但没有任何效果。当我将 targetSdkVersion 恢复到 29 时,该应用程序运行良好。

app.gradle

android {
  compileSdkVersion 30
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 30
    generatedDensities = []
    multiDexEnabled true
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

dependencies {
    implementation "androidx.multidex:multidex:2.0.1"
}

package.json 依赖项

"dependencies": {
    "@angular/animation": "^4.0.0-beta.8",
    "@angular/animations": "~11.0.0",
    "@angular/common": "~11.0.0",
    "@angular/compiler": "~11.0.0",
    "@angular/core": "~11.0.0",
    "@angular/forms": "~11.0.0",
    "@angular/platform-browser": "~11.0.0",
    "@angular/platform-browser-dynamic": "~11.0.0",
    "@angular/router": "~11.0.0",
    "@nativescript/angular": "~11.0.0",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/datetimepicker": "~2.0.0",
    "@nativescript/iqkeyboardmanager": "~2.0.0",
    "@nativescript/picker": "^3.0.1",
    "@nativescript/theme": "~2.3.3",
    "@nativescript/webpack": "^3.0.0",
    "@nstudio/nativescript-exoplayer": "^5.0.6",
    "@nstudio/nativescript-snackbar": "^2.1.0",
    "@ticnat/nativescript-searchable-select": "^1.0.7",
    "credit-card-type": "^9.1.0",
    "moment": "^2.29.1",
    "nativescript-audio": "^6.2.0",
    "nativescript-dna-netservices": "^1.1.0",
    "nativescript-fontawesome": "^1.0.0",
    "nativescript-iap": "^8.0.3",
    "nativescript-screen-orientation": "^2.0.0",
    "nativescript-sentry": "^2.0.0",
    "nativescript-sqlite": "^2.6.4",
    "nativescript-ui-dataform": "^7.0.4",
    "nativescript-ui-sidedrawer": "~9.0.0",
    "nativescript-zip": "^4.0.2",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.6.0",
    "xcode": "^3.0.1",
    "zone.js": "~0.11.1"
  },
  "devDependencies": {
    "@angular/cli": "^11.0.2",
    "@angular/compiler-cli": "~11.0.0",
    "@nativescript/android": "7.0.1",
    "@nativescript/ios": "7.1.1",
    "@nativescript/schematics": "^10.1.0",
    "@nativescript/types": "7.0.0",
    "@ngtools/webpack": "~11.0.0",
    "@types/jest": "^26.0.15",
    "codelyzer": "~6.0.0",
    "node-sass": "^4.14.1",
    "ts-patch": "^1.3.2",
    "tslint": "~6.1.3",
    "typescript": "~4.0.0"
  }

I have an app in NativeScript + Angular, when i put targetSdkVersion from 29 to 30 (as google needs) on App_Resources\Android\app.gradle, the app crashes on start and show nothing, just closes itself. I tryed so many things to fix, and nothing works. When i back targetSdkVersion to 29, the app works perfectly.

app.gradle

android {
  compileSdkVersion 30
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 30
    generatedDensities = []
    multiDexEnabled true
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

dependencies {
    implementation "androidx.multidex:multidex:2.0.1"
}

package.json dependencies

"dependencies": {
    "@angular/animation": "^4.0.0-beta.8",
    "@angular/animations": "~11.0.0",
    "@angular/common": "~11.0.0",
    "@angular/compiler": "~11.0.0",
    "@angular/core": "~11.0.0",
    "@angular/forms": "~11.0.0",
    "@angular/platform-browser": "~11.0.0",
    "@angular/platform-browser-dynamic": "~11.0.0",
    "@angular/router": "~11.0.0",
    "@nativescript/angular": "~11.0.0",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/datetimepicker": "~2.0.0",
    "@nativescript/iqkeyboardmanager": "~2.0.0",
    "@nativescript/picker": "^3.0.1",
    "@nativescript/theme": "~2.3.3",
    "@nativescript/webpack": "^3.0.0",
    "@nstudio/nativescript-exoplayer": "^5.0.6",
    "@nstudio/nativescript-snackbar": "^2.1.0",
    "@ticnat/nativescript-searchable-select": "^1.0.7",
    "credit-card-type": "^9.1.0",
    "moment": "^2.29.1",
    "nativescript-audio": "^6.2.0",
    "nativescript-dna-netservices": "^1.1.0",
    "nativescript-fontawesome": "^1.0.0",
    "nativescript-iap": "^8.0.3",
    "nativescript-screen-orientation": "^2.0.0",
    "nativescript-sentry": "^2.0.0",
    "nativescript-sqlite": "^2.6.4",
    "nativescript-ui-dataform": "^7.0.4",
    "nativescript-ui-sidedrawer": "~9.0.0",
    "nativescript-zip": "^4.0.2",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.6.0",
    "xcode": "^3.0.1",
    "zone.js": "~0.11.1"
  },
  "devDependencies": {
    "@angular/cli": "^11.0.2",
    "@angular/compiler-cli": "~11.0.0",
    "@nativescript/android": "7.0.1",
    "@nativescript/ios": "7.1.1",
    "@nativescript/schematics": "^10.1.0",
    "@nativescript/types": "7.0.0",
    "@ngtools/webpack": "~11.0.0",
    "@types/jest": "^26.0.15",
    "codelyzer": "~6.0.0",
    "node-sass": "^4.14.1",
    "ts-patch": "^1.3.2",
    "tslint": "~6.1.3",
    "typescript": "~4.0.0"
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉城メ夜风 2025-01-16 03:12:42

一定是某些插件在 sdk30 上无法正常工作的问题。
一项一项检查可能会很烦人,所以尝试添加到 AndroidManifest.xml 中。
如果它不能解决问题,您应该花一些时间来查找
导致问题的确切插件。

谢谢MishaMashina!将 android:allowNativeHeapPointerTagging="false" 放入我的 AndroidManifest.xml 解决了我的问题。

另外,在解决第一个问题后,我还遇到了 API 30 的另一个问题。当我尝试在 webView 中加载内容时,出现了 ERR_ACCESS_DENIED 错误。我解决了这个问题,在加载 webView 时在代码上设置此属性:

webView = args.object.android;
...
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowContentAccess(true);

Must be an issue with some of the plugins not working well with sdk30.
It might be tiresome to check one by one, so try adding to AndroidManifest.xml.
If it doesn't fix the issue, you should devote some time into finding
the exact plugin(s) that cause the problem.

Thanks MishaMashina! Putting android:allowNativeHeapPointerTagging="false" in my AndroidManifest.xml solved my problem.

In aditional, i had another problem with API 30 after solved the first one. i was taking the ERR_ACCESS_DENIED error when i tryed load content in a webView. And i solved it setting this properties on the code when loading the webView:

webView = args.object.android;
...
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowContentAccess(true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文