Android官方技術文檔翻譯——IntelliJ 項目遷移

來源:互聯網
上載者:User

標籤:

本文譯自Android官方技術文檔《Migrating from IntelliJ Projects》,原文地址:http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects。

上一篇介紹了如何上一篇介紹了如何把一個Eclipse上的Android項目遷移到 Android Studio,這一篇繼續介紹對 IntelliJ項目的遷移。

翻譯不易,轉載請註明CSDN部落格上的出處:

http://blog.csdn.net/maosidiaoxian/article/details/42736561

翻譯工作耗時費神,如果你覺得本文翻譯得還OK,請點擊文末的“頂”;如有錯訛,敬請指正。謝謝。


IntelliJ 項目遷移在未來,我們可能會在Android Studio 中提供自動遷移的選項。
現在,將您的 IntelliJ 項目遷移到 Android Gradle 項目 (它可以匯入到 IntelliJ 然後在 IntelliJ中直接支援),需要遵循以下步驟:
  • 建立一個基本的“build.gradle”檔案。與你在建立一個新項目時由 Android Studio 所建立的預設 Gradle 檔案檔案,下面的 gradle 檔案將把原始碼目錄指向現有檔案夾 (例如res/, src/) 而不是用 Gradle 項目的預設新目錄結構 (src/main/java/, src/main/res/等)。下面給出一個樣本 gradle 檔案。
  • 確定您正在使用哪一個庫項目(如 ActionBarSherlock)。在 Gradle 中你不再需要把這些庫作為原始碼項目加進去;你可以把它們簡單地用依賴來引用,並且構建系統將處理接下來的部分;進行下載,合并資源和清單項,等等。對於每個庫,會尋找相應的AAR庫的依賴名稱(前提是,所討論的庫已經被作為一個android 庫歸檔檔案被更新),然後把它們添加到依賴的部分中去。
    • 為找到關於庫的合適的聲明語句,你可能會發現以下部落格對你有用:http://gradleplease.appspot.com/
  • 通過在您的項目中運行gradle assembleDebug可以測試您的構建。如果你之前不是用 Gradle 來構建的,需要從 http://www.gradle.org/downloads 中安裝它。請注意,當您通過 Studio 建立新項目時,我們會在項目的根目錄建立一個 gradle wrapper 指令碼 (“gradlew”和“gradlew.bat”),所以該項目的任何使用者只需在你的項目中運行“gradlew assembleDebug”等命令,gradle 就會自動下載和安裝。然而,您現有的 IntelliJ 項目大概還沒有這個 gradle 指令碼。
  • 注意,IntelliJ 的 Android 項目一般遵循和 Eclipse ADT 項目相同的結構,所以Eclipse 遷移指南中的介紹可能對你會有所協助。
build.gradle: buildscript {     repositories {         mavenCentral()     }     dependencies {         classpath ‘com.android.tools.build:gradle:0.5.+‘     } } apply plugin: ‘android‘
dependencies {     compile fileTree(dir: ‘libs‘, include: ‘*.jar‘) }
android {     compileSdkVersion 18     buildToolsVersion "18.0.1"
    sourceSets {         main {             manifest.srcFile ‘AndroidManifest.xml‘             java.srcDirs = [‘src‘]             resources.srcDirs = [‘src‘]             aidl.srcDirs = [‘src‘]             renderscript.srcDirs = [‘src‘]             res.srcDirs = [‘res‘]             assets.srcDirs = [‘assets‘]         }
        // Move the tests to tests/java, tests/res, etc...         instrumentTest.setRoot(‘tests‘)
        // Move the build types to build-types/<type>         // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...         // This moves them out of them default location under src/<type>/... which would         // conflict with src/ being used by the main source set.         // Adding new build types or product flavors should be accompanied         // by a similar customization.         debug.setRoot(‘build-types/debug‘)         release.setRoot(‘build-types/release‘)     } }
在你已經完成了基本的設定之後,有關如何自訂你的構建的詳細資料,請參閱新構建系統的 使用者指南 。其他資訊,請參閱該構建系統的概述頁。

Android官方技術文檔翻譯——IntelliJ 項目遷移

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.