2016-12-27 44 views
0

我想添加nativescript-telerik-ui並在空白項目中使用側邊抽屜。該項目建立正常,但我得到如下所示的錯誤,如果我嘗試連接的設備上運行的代碼:使用Nativescript的RadSideDrawer時出錯

enter image description here

,直到我試圖用抽屜上的一個項目是正常運行頁面。

這裏是我的package.json:

{ 
 
    "description": "NativeScript Application", 
 
    "license": "SEE LICENSE IN <your-license-filename>", 
 
    "readme": "NativeScript Application", 
 
    "repository": "<fill-your-repository-here>", 
 
    "nativescript": { 
 
    "id": "org.nativescript.drawertest", 
 
    "tns-android": { 
 
     "version": "2.4.1" 
 
    } 
 
    }, 
 
    "dependencies": { 
 
    "nativescript-telerik-ui": "^1.5.1", 
 
    "nativescript-theme-core": "^0.2.1", 
 
    "tns-core-modules": "2.4.4" 
 
    }, 
 
    "devDependencies": { 
 
    "babel-traverse": "6.21.0", 
 
    "babel-types": "6.21.0", 
 
    "babylon": "6.14.1", 
 
    "lazy": "1.0.11", 
 
    "nativescript-dev-android-snapshot": "^0.*.*" 
 
    } 
 
}

我也試過在Genymotion運行它。這裏是我到那裏的錯誤:

An uncaught Exception occurred on "main" thread. 
 
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.drawertest/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
 
Calling js method onCreate failed 
 

 
Error: Building UI from XML. @file:///app/main-page.xml:20:5 
 
> Module 'ui/rad-side-drawer' not found for element 'RadSideDrawer'. 
 
    > com.tns.NativeScriptException: Failed to find module: "ui/rad-side-drawer", relative to: app/tns_modules/ 
 
     com.tns.Module.resolvePathHelper(Module.java:159) 
 
    com.tns.Module.resolvePath(Module.java:60) 
 
    com.tns.Runtime.callJSMethodNative(Native Method) 
 
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1022) 
 
    com.tns.Runtime.callJSMethodImpl(Runtime.java:907) 
 
    com.tns.Runtime.callJSMethod(Runtime.java:895) 
 
    com.tns.Runtime.callJSMethod(Runtime.java:879) 
 
    com.tns.Runtime.callJSMethod(Runtime.java:871) 
 
    com.tns.NativeScriptActivity.onCreate(android.app.Activity.java) 
 
    android.app.Activity.performCreate(

我也許應該提到,我得到類似的錯誤,當我試圖使用的IOS模擬器我的Mac上運行相同的代碼。

我缺少什麼?

謝謝。

編輯:原來我有一個語法錯誤。一旦糾正,一切都按預期工作。

+2

認沽XML代碼太:),也許你已經失去了一些東西像xlmns:抽屜或類似的東西 –

+0

@MarekMaszay:良好的通話。我開始看着XML,我確實有一個語法錯誤。 – dpdragnev

回答

0

從錯誤日誌中看起來您已經爲RadSideDrawer組件(「ui/rad-side-drawer」)聲明瞭不正確的命名空間。該組件是nativescript-telerik-ui插件的一部分,該插件可以在node_modules文件夾中的nativescript-telerik-ui-pro/sidedrawer模塊中找到。

欲瞭解更多詳情,你可以看看官方文檔here

簡單地聲明這個命名空間,並在XML聲明RadSideDrawer時使用它:

xmlns:drawer="nativescript-telerik-ui-pro/sidedrawer" 
相關問題