标签: nativescript

NPM 安装在 docker 容器中失败 - npm WARN tar ENOENT: no such file or directory

我正在尝试编译一个 Nativescript 应用程序,作为我们 Teamcity 部署策略的一部分。

当我运行 NPM install 时,我在尝试查找文件时遇到 ENOENT 错误,如下所示:

  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-7722a2ea/fp/assignAll.js'
  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-8fa77886/fp/create.js'
  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-7722a2ea/fp/assignAllWith.js'
  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-b2787570/fp/assign.js'
  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-8fa77886/fp/curry.js'
  npm WARN tar ENOENT: no such file or directory, open '/home/my_user/BuildAgent/work/my_application/node_modules/.staging/lodash-b2787570/fp/assignAll.js'
  npm WARN tar …
Run Code Online (Sandbox Code Playgroud)

teamcity node.js npm nativescript

20
推荐指数
1
解决办法
9076
查看次数

当我使用Typescript时,如何在NativeScript中访问Native api

当我用tns创建两个新的应用程序时,一个是常规的js版本,一个是typescript.当我尝试访问本机库时,我在打字稿版本中遇到一个奇怪的错误.

当我使用console.log(pow(x,y))创建一个加载的函数时,它与js版本一起工作正常,但是typescript版本因此错误而崩溃.

error TS2304: Cannot find name 'pow'.
Run Code Online (Sandbox Code Playgroud)

为什么?

TS:

import { EventData } from "data/observable";
import { Page } from "ui/page";
import { HelloWorldModel } from "./main-view-model";

// Event handler for Page "navigatingTo" event attached in main-page.xml
export function navigatingTo(args: EventData) {
    // Get the event sender
    var page = <Page>args.object;
    page.bindingContext = new HelloWorldModel();
}

export function loaded() {
    console.log('Hello World')
    console.log('pow(2.5, 3) = ', pow(2.5, 3));
}
Run Code Online (Sandbox Code Playgroud)

JS:

var createViewModel = require("./main-view-model").createViewModel;

function onNavigatingTo(args) {
    var page …
Run Code Online (Sandbox Code Playgroud)

nativescript

19
推荐指数
1
解决办法
5565
查看次数

Native Script与本机和离子框架之间的差异

Native Script和ionic框架分别用于构建具有Web视图和无Web视图的IOS和Android应用程序.

在上述技术中,Web视图的概念与没有Web视图之间存在混淆.

Native Script和离子框架之间的主要区别是什么.哪一个提供最佳性能?

任何人都可以解释这个或提供一些相关的东西.

(如果我的理解错误,请纠正我)

cordova hybrid-mobile-app ionic-framework nativescript react-native

15
推荐指数
2
解决办法
9098
查看次数


从CLI [NativeScript]一起打包手持和可穿戴的Android应用程序

我正在尝试使用NativeScript for Android构建Phone + Wear应用程序.我已经能够单独构建它们并在Android模拟器上运行它们.问题是我无法正确打包它们,我的意思是,我无法将它们打包在一起以便只安装一个APK,这将在手机中安装掌上电脑应用程序并将可穿戴应用程序推入手表中.

方法和代码

甚至你写的关于Android Wear的帖子也已经过时了,示例代码repo丢失了,我已经能够构建一个在Android Wear模拟器中正常运行的NativeScript应用程序.

我还有一个使用NativeScript构建的普通手机应用程序,它可以在模拟器和我自己的设备中正常运行(如下所述).

我尝试按照官方文档中描述的步骤打包应用程序:"分别签署可穿戴设备和掌上电脑应用程序"和"手动打包".我尝试了两种包装方法,但没有人为我工作(最后一种也是本文中描述的那种).

您可以看到这两个应用程序的文件AndroidManifest.xmlapp.gradle文件以及我正在执行的用于打包已签名应用程序的命令:

可穿戴应用文件

bilbonbizi /耐磨/的package.json

  "nativescript": {
    "id": "com.berriart.bilbonbizi",
    "tns-android": {
      "version": "2.5.0"
    }
  },
Run Code Online (Sandbox Code Playgroud)

bilbonbizi /耐磨/应用/ App_Resources /安卓/ AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="__PACKAGE__"
    android:versionCode="1"
    android:versionName="1.0">

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

    <uses-sdk
        android:minSdkVersion="20"
        android:targetSdkVersion="__APILEVEL__"/>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

    <uses-feature android:name="android.hardware.location.gps" />
    <uses-feature android:name="android.hardware.location.network" />
    <uses-feature …
Run Code Online (Sandbox Code Playgroud)

android hybrid-mobile-app android-gradle-plugin nativescript wear-os

14
推荐指数
1
解决办法
290
查看次数

在 MIUI 11 / 12 下激活暗模式时的主题问题

编辑:MIUI 强制在我的应用程序中激活暗模式,因此该应用程序看起来很糟糕。

在我的应用程序的某些部分中,当我将颜色设置为“白色”时,它将显示为白色。

如果我将其设置为“灰色”,它将显示为灰色。

如果我将其设置为“红色”,它将显示为红色。

但是:如果我将它设置为“黑色”,它将是“白色!”

我怎么解决这个问题??

colors nativescript

14
推荐指数
2
解决办法
9391
查看次数

在ngOnInit promise中数组推送后,Angular 2不刷新视图

我创建了一个带有角度2的NativeScript应用程序,我有一个对象数组,我期望在应用程序的前端看到.行为是,如果我直接在ngOnInit()内部将对象推入数组,它可以工作,但如果我在ngOnInit()中创建一个承诺它不起作用.这是代码:

export class DashboardComponent {
     stories: Story[] = [];

     pushArray() {
         let story:Story = new Story(1,1,"ASD", "pushed");
         this.stories.push(story);
     }

     ngOnInit() {
         this.pushArray(); //this is shown

         var promise = new Promise((resolve)=>{
             resolve(42);
             console.log("promise hit");
         });

         promise.then(x=> {
             this.pushArray(); //this is NOT shown
         });
     }
 }
Run Code Online (Sandbox Code Playgroud)

相对的html是:

<Label *ngFor="let story of stories" [text]='story.message'></Label>
Run Code Online (Sandbox Code Playgroud)

当应用程序启动时,我只看到一次推送,但是我创建了一个触发"console.log(JSON.stringify(this.stories))"的按钮;" 在那一刻,当我点击按钮时,ui似乎检测到更改的数组,并出现另一个推送的对象.

编辑:

我在这个帖子中创建了一个更简单的例子:Angular 2:当我在ngOnInit中更改promise.than中的变量时,视图不会刷新

es6-promise nativescript angular2-nativescript angular

13
推荐指数
1
解决办法
8216
查看次数

如何在nativescript中设置方向

您好我想知道如何在nativescript中设置设备方向.具体来说,我希望我写的应用程序始终保持相同的方向(纵向),以便旋转设备不会导致它进入横向.

我尝试了nativescript-orientation插件和setOrientation.

var orientation = require('nativescript-orientation');
console.log(JSON.stringify(orientation));// outputs JS: {}
orientation.setOrientation("portrait"); 
Run Code Online (Sandbox Code Playgroud)

但是我收到错误"无法读取属性setOrientation of undefined.tns插件列表显示插件已安装.此外,我尝试删除platforms/android目录并运行tns platform add android相同的结果.

我也尝试将各种组合android:screenOrientation="portrait"放入AndroidManifest.xml但没有成功.

App_resources内部的AndroidManifest.xml看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="__PACKAGE__"
    android:versionCode="1"
    android:versionName="1.0">

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="__APILEVEL__"/>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:screenOrientation="portrait"
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.tns.NativeScriptActivity"
            android:label="@string/title_activity_kimera"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@style/LaunchScreenTheme">
            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.tns.ErrorReportActivity"/>
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

android screen-orientation nativescript

13
推荐指数
2
解决办法
7090
查看次数

Nativescript无法识别Xcode(High Sierra)

我在High Sierra上使用Xcode版本9.0.1(9A1004).运行时,tns doctor我收到以下警告:

WARNING: Xcode is not installed or is not configured properly.
You will not be able to build your projects for iOS or run them in the iOS Simulator.
To be able to build for iOS and run apps in the native emulator, verify that you have installed Xcode.
Run Code Online (Sandbox Code Playgroud)

如果我运行安装脚本,我得到:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
Xcode is not installed or not configured properly. Download, …
Run Code Online (Sandbox Code Playgroud)

xcode nativescript macos-high-sierra

13
推荐指数
1
解决办法
2054
查看次数

如何指定或获取本机脚本文本字段的资源ID

我们正在为我们的移动应用程序使用带有角度的nativescript.我想使用Google Play预启动报告功能,但我们的应用需要输入密码.Google Play允许指定密码,但您需要一个资源名称,以便测试脚本可以识别密码的放置位置.

如何在视图中或通过后面的代码或通过任何其他方式指定或接收本机文本字段的资源名称?

有问题的观点:

      <StackLayout class="form">
    <GridLayout columns="*,90" rows="50">
      <TextField #inviteTx
        col="0"
        height="50"
        autocorrect="false"
        returnKeyType="next"
        (returnPress)="enter(inviteTx.text)"
        class="input input-border"
        secure="false"
        keyboardType="url">
      </TextField>
      <Button col="1" height="50" class="btn btn-primary w-full fa" text="START &#xf105;" (tap)="enter(inviteTx.text)"></Button>
    </GridLayout>
  </StackLayout>
Run Code Online (Sandbox Code Playgroud)

我做了一些研究,发现在原生android中,可以通过添加android:id属性为TextField添加一个id.

<TextView android:id="@+id/nameTextbox"/>
Run Code Online (Sandbox Code Playgroud)

这似乎不适用于nativescript,之后我无法在R.java中找到该资源.

android google-play nativescript angular2-nativescript google-play-console

13
推荐指数
1
解决办法
1313
查看次数