首页 > 解决方案 > 更改 nativescript android api 版本

问题描述

我在用:

nativescript has an 8.0.1 version and is up to date.
@nativescript/core has an 8.0.4 version and is up to date.
@nativescript/ios are not installed.
@nativescript/android has an 8.0.0 version and is up to date.

我试图让我的应用程序以minSdkVersion19 为目标,但无论我做什么,该应用程序都是使用版本 17 编译的。

我试过了:

我环顾四周,找不到解决方案,尽管我遇到了一些关于同一问题的帖子。他们都没有解决这个问题。

有问题的项目在这里,只需克隆它并运行tns build android。它将与android-platform-17.d.ts. 如果您想在使用平台 19 中的类型时看到构建失败,只需添加let test = new android.bluetooth.BluetoothGattCallback().

标签: androidgradlenativescript

解决方案


node_modules/@nativescript/types-android/lib/android.d.ts文件中的默认值<reference path="./android-17.d.ts" />是使用android-platform-17.d.ts. 尝试将值更改<reference path="./android-19.d.ts" />为该文件中的值并构建它。

我尝试在您的代码中更改它后进行构建,并且由于不同的原因构建失败,即Cannot create an instance of an abstract class. 发生此错误是因为android.bluetooth.BluetoothGattCallback实际上是一个类,但您正试图像函数一样使用它。


推荐阅读