NativeScript Android API 版本检查
NativeScript Android API Version check
我使用以下命令将 android 平台添加到我的 nativescript 应用程序
tns platform add android
现在我不知道添加了哪个 API 版本的平台?
我该如何解决这个问题?
platform add android
命令将获取所有必要的文件以开始为 Android 构建应用程序。我假设您询问的是 android 应用程序的 compileSdk 版本 - 这是在 Build 时间确定的。
当您执行 tns build/run android
时,除非指定 --compileSdk 21/22/23/24/25
标志,否则将使用系统上可用的最新版本。
例如,如果我最近刚从 Android SDK 管理器下载 Android SDK 构建工具和 SDK 平台 25,则上传到设备上的应用程序包将使用平台构建25.
Medium 有一篇关于 compileSdk、targetSdk 和 minSdk 的好文章,我推荐你阅读 -> https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd#.eoe0x9isx
祝你好运!
最新文档说:
https://docs.nativescript.org/angular/ng-framework-modules/platform
import { isAndroid, isIOS, device, screen } from "tns-core-modules/platform";
class DeviceInfo {
constructor(
public model: string,
public deviceType: string,
public os: string,
public osVersion: string,
public sdkVersion: string,
public language: string,
public manufacturer: string,
public uuid: string
) { }
}
class ScreenInfo {
constructor(
public heightDIPs: number,
public heightPixels: number,
public scale: number,
public widthDIPs: number,
public widthPixels: number
) { }
}
@Component({
moduleId: module.id,
templateUrl: "./platform-module-example.html"
})
export class PlatformModuleExampleComponent {
public isItemVisible: boolean = false;
public deviceInformation: DeviceInfo;
public isItemVisibleScreenInfo: boolean = false;
public screenInformation: ScreenInfo;
public deviceInfoButton: string = "Show device info";
public screenInfoButton: string = "Show/Hide screen info";
constructor() {
this.deviceInformation = new DeviceInfo(
device.model,
device.deviceType,
device.os,
device.osVersion,
device.sdkVersion,
device.language,
device.manufacturer,
device.uuid);
this.screenInformation = new ScreenInfo(
screen.mainScreen.heightDIPs,
screen.mainScreen.heightPixels,
screen.mainScreen.scale,
screen.mainScreen.widthDIPs,
screen.mainScreen.widthPixels);
}
public checkPlatformType(args) {
let message = "";
if (isAndroid) {
message = "You are using Android device";
} else if (isIOS) {
message = "You are using IOS device";
}
alert(message);
}
public deviceInfo(args) {
if (this.isItemVisible) {
this.isItemVisible = false;
this.deviceInfoButton = "Show device info";
} else {
this.isItemVisible = true;
this.deviceInfoButton = "Hide device info";
}
}
public screenInfo(args) {
if (this.isItemVisibleScreenInfo) {
this.isItemVisibleScreenInfo = false;
this.screenInfoButton = "Show screen info";
} else {
this.isItemVisibleScreenInfo = true;
this.screenInfoButton = "Hide screen info";
}
}
}
我使用以下命令将 android 平台添加到我的 nativescript 应用程序
tns platform add android
现在我不知道添加了哪个 API 版本的平台?
我该如何解决这个问题?
platform add android
命令将获取所有必要的文件以开始为 Android 构建应用程序。我假设您询问的是 android 应用程序的 compileSdk 版本 - 这是在 Build 时间确定的。
当您执行 tns build/run android
时,除非指定 --compileSdk 21/22/23/24/25
标志,否则将使用系统上可用的最新版本。
例如,如果我最近刚从 Android SDK 管理器下载 Android SDK 构建工具和 SDK 平台 25,则上传到设备上的应用程序包将使用平台构建25.
Medium 有一篇关于 compileSdk、targetSdk 和 minSdk 的好文章,我推荐你阅读 -> https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd#.eoe0x9isx
祝你好运!
最新文档说:
https://docs.nativescript.org/angular/ng-framework-modules/platform
import { isAndroid, isIOS, device, screen } from "tns-core-modules/platform";
class DeviceInfo {
constructor(
public model: string,
public deviceType: string,
public os: string,
public osVersion: string,
public sdkVersion: string,
public language: string,
public manufacturer: string,
public uuid: string
) { }
}
class ScreenInfo {
constructor(
public heightDIPs: number,
public heightPixels: number,
public scale: number,
public widthDIPs: number,
public widthPixels: number
) { }
}
@Component({
moduleId: module.id,
templateUrl: "./platform-module-example.html"
})
export class PlatformModuleExampleComponent {
public isItemVisible: boolean = false;
public deviceInformation: DeviceInfo;
public isItemVisibleScreenInfo: boolean = false;
public screenInformation: ScreenInfo;
public deviceInfoButton: string = "Show device info";
public screenInfoButton: string = "Show/Hide screen info";
constructor() {
this.deviceInformation = new DeviceInfo(
device.model,
device.deviceType,
device.os,
device.osVersion,
device.sdkVersion,
device.language,
device.manufacturer,
device.uuid);
this.screenInformation = new ScreenInfo(
screen.mainScreen.heightDIPs,
screen.mainScreen.heightPixels,
screen.mainScreen.scale,
screen.mainScreen.widthDIPs,
screen.mainScreen.widthPixels);
}
public checkPlatformType(args) {
let message = "";
if (isAndroid) {
message = "You are using Android device";
} else if (isIOS) {
message = "You are using IOS device";
}
alert(message);
}
public deviceInfo(args) {
if (this.isItemVisible) {
this.isItemVisible = false;
this.deviceInfoButton = "Show device info";
} else {
this.isItemVisible = true;
this.deviceInfoButton = "Hide device info";
}
}
public screenInfo(args) {
if (this.isItemVisibleScreenInfo) {
this.isItemVisibleScreenInfo = false;
this.screenInfoButton = "Show screen info";
} else {
this.isItemVisibleScreenInfo = true;
this.screenInfoButton = "Hide screen info";
}
}
}