nativescript-camera version 3.3.0在框架android 2.5.0中不兼容

时间:2018-04-10 08:11:34

标签: android nativescript

我正在使用nativescript构建应用程序。要访问相机,我使用的是插件nativescript-camera。

但是当我安装插件时,我收到一条错误消息:  " nativescript-camera 3.0.0 for android与当前安装的框架版本2.5.0不兼容。"

有谁知道,出了什么问题?我试图更新插件nativescript-camera,但结果相同。

有我的代码: 主page.xml

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
    <StackLayout>
        <Label text="Take a picture yo" class="title" />
        <Image id="myImage" />
        <Button text="Take" tap="onTake" />
    </StackLayout>
</Page>

主page.js

var application = require("application");
var cameraModule = require("nativescript-camera");
var myImage;
exports.pageLoaded = function(args) {
    var page = args.object;
    myImage = page.getViewById("myImage");
    myImage.src = "https://placehold.it/150x150";
    page.bindingContext = {};
}
exports.onTake=function(args){
    if(application.android)
    {
        var permissions = require('nativescript-permissions');
        permissions.requestPermission(android.Manifest.permission.CAMERA, "I need these permissions because I'm cool")
          .then(function() {
             console.log("Permission OK");
              cameraModule.takePicture({
        width: 300,
        height: 300,
        keepAspectRatio: true,

    }).then(function (imageSource) {
        myImage.src="";
        myImage.src = imageSource;
    });
          })
          .catch(function() {
             console.log("Permission Failed");
          });    
    }
}

0 个答案:

没有答案