【使用Ubuntu SDK】入門篇——qtcreator 運行qmlscene時 module "Ubuntu.Components" is not installed 錯誤分析和解決


從有Ubuntu要准備發布Phone版本就在開始關注了,尤其是其官方開發網站上的相關教程的閱讀;前一段時間也試着搭建環境和進行初步的示例開發,網址為:

http://developer.ubuntu.com/get-started/gomobile/

現在更新后的教程是:

Get the Ubuntu SDK preview

The first thing you'll need to do is to install the tools and its dependencies. The installation will take place from PPAs, which are archives of packages that enable rapid delivery of updates. It’s an easy step that should take just a few minutes.

Install Qt 5

The Ubuntu SDK preview is built upon the latest version of the Qt framework, which we’re going to install now:

  1. Open a terminal by pressing the Ctrl+Alt+T key combination
  2. Enter the following command, pressing Enter at the end of the line and following the prompts
sudo add-apt-repository ppa:canonical-qt5-edgers/qt5-proper

 

Install the Ubuntu SDK preview

Once the dependencies are resolved, we’re going to install the Ubuntu UI toolkit as part of the Ubuntu SDK:

  1. If it wasn't open already, launch a terminal by pressing the Ctrl+Alt+T key combination
  2. Enter the following command, pressing Enter at the end of the line and following the prompts
sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install ubuntu-sdk notepad-qml

 

當初沒有這么好運,兩行代碼跟上面的有些出入,比如,安裝的是qt5-beta1的ppa,而不是現在的qt5-proper,當時添加了個http://ppa.launchpad.net/ui-toolkit/ppa/ubuntu 的庫,自動安裝的Ubuntu的Components在/opt/qt5/imports/Ubuntu目錄下,可是當前的更新后的qt-components-ubuntu包把文件都安裝到了如下目錄中:

/usr/lib/i386-linux-gnu/qt5/qml/Ubuntu/

雖然參考了一些教程,設置了環境變量:

export QML_IMPORT_PATH=/usr/lib/i386-linux-gnu/qt5/qml:$QML_IMPORT_PATH

也在測試項目中添加了路徑配置代碼:

    /* List of plugin directories passed to QML runtime */
    importPaths: [ "/usr/lib/i386-linux-gnu/qt5/qml","." ,"/usr/bin", "/opt/qt5/imports" ]

但是運行qmlscene的時候,還是提示錯誤:

Starting external tool '/opt/qt5/bin/qmlscene' t.qml
Got bus address:  "unix:abstract=/tmp/dbus-szRCO8tHBe,guid=9bef4d79deacf239b947461e512a167e" 

Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-szRCO8tHBe,guid=9bef4d79deacf239b947461e512a167e" 

Registered DEC:  true 

file:///t.qml:2:1: module "Ubuntu.Components" is not installed 
     import Ubuntu.Components 0.1 
     ^ 

有待繼續研究該路徑和程序問題!總的來說是版本混亂了,要清理原來版本的配置、實現新版本的依賴和程序的調用關系!

先分析新版本的Ubuntu-SDK里面的依賴方式:

使用gdebi程序打開下載好的Ubuntu-SDK的開發包: ubuntu-sdk_0.1~bzr20130204-0ubuntu1~quantal1~test4_i386.deb

該包中說明如下:

Ubuntu SDK
This package depends on all the needed packages of the Ubuntu SDK:
* Qt 5
* Qt Creator
* Ubuntu UI Toolkit
* Demos and examples 

而進行qml文件調試的程序是qmlscene,應該屬於qt5的開發包;故繼續追蹤新的安裝路徑:

同樣用gdebi文件打開包: qtbase5-dev-tools_5.0.0-0ubuntu1~quantal2~test3~nonupstreampatched2_i386.deb

發現里面程序的安裝路徑為:

/usr/lib/i386-linux-gnu/qt5/bin/

新版Ubuntu-SDK的程序都安裝在該目錄下!重新配置qtcreator里面的qmlscene預覽程序的路徑,快捷鍵啟動成功了!

配一個截圖搞定! 

大家現在去按照官網說明安裝相應工具后,也注意教程中調適工具的路徑設置為新的喲!

網站: http://developer.ubuntu.com/get-started/gomobile/#step-get-toolkit

路徑: /usr/lib/i386-linux-gnu/qt5/bin/

更新后的教程應該是:

Here’s a tip: although Qt Creator does not yet support qmlscene as QML viewer, you can invoke it from within the IDE. Here’s how:

  1. In Qt Creator, go to Tools > Options…
  2. Choose the External Tools tab, then in the pane select the Preview (qmlviewer) entry
  3. On the Executable: field on the right, replace the contents with  /usr/lib/i386-linux-gnu/qt5/bin/qmlscene.
  4. Optionally change the command name by double-clicking on the Preview (qmlviewer) entry from above. You can call it Preview (qmlscene).
  5. Click on OK to save the changes.

Now you’ll be able to view your app through the Tools > External > Qt Quick > Preview (qmlscene) menu entry, from within the IDE and you won’t need a terminal anymore.

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM