我使用以下命令将android平台添加到我的nativescript应用程序
tns platform add android
现在我无法确定添加了哪个API版本的平台?
我怎么能弄清楚这一点?
答案 0 :(得分:5)
platform add android
命令将获取所有必要的文件以开始为Android构建应用程序。我假设您正在询问Android应用程序的compileSdk版本 - 这是在 Build 时确定的。
除非指定tns build/run android
标志,否则执行--compileSdk 21/22/23/24/25
时,将使用系统上可用的最新版本。
例如,如果我刚刚从Android SDK Manager下载了Android SDK Build-Tools和SDK-Platform 25,那么上传到设备上的应用程序包将使用平台25构建。
Medium有关于我推荐你阅读的compileSdk,targetSdk和minSdk的好文章 - > https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd#.eoe0x9isx
祝你好运!答案 1 :(得分:1)
最新文档说:
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";
}
}
}