android - 更改 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.
我试图让我的应用程序以minSdkVersion
19 为目标,但无论我做什么,该应用程序都是使用版本 17 编译的。
我试过了:
- 设置
minSdkVersion 19
在App_Resources/Android/app.gradle
- 添加
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29"/>
到App_Resources/Android/src/main/AndroidManifest.xml
我环顾四周,找不到解决方案,尽管我遇到了一些关于同一问题的帖子。他们都没有解决这个问题。
有问题的项目在这里,只需克隆它并运行tns build android
。它将与android-platform-17.d.ts
. 如果您想在使用平台 19 中的类型时看到构建失败,只需添加let test = new android.bluetooth.BluetoothGattCallback()
.
解决方案
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
实际上是一个类,但您正试图像函数一样使用它。
推荐阅读
- django-rest-framework - 使用与 faker 集成的 factory boy 从名称列表中进行选择
- json - 将请求内容 json 解析为 Laravel 中的对象
- linux - 如何在 Linux 系统上启动内存中的应用程序
- reactjs - 在反应原生中保存状态
- c# - 属性或索引器不能分配给它在 C# 中是只读的
- discord.js - 每台服务器运行一个 Discord bot 实例,因此 bot 不会在每台服务器上打开
- android - Kotlin 程序在将 clickListener 设置为在膨胀的 XML 中定义的按钮时抛出 nullPointerException,不知道该去哪里
- angular - 如何使用 RxJS 将我的二维数组重新映射到目标模式?
- r - 如何解决:R CMD检查报告警告和错误
- arrays - 如何使用 matplotlib 为二维数组中的所有(仅 4 种)类型的值绘制图例?