一個是對整個project,要兩個都引入才算真的import!!
這次就來真正完整教學!!
這次就略過開新專案的過程直接進到主題
專案名稱: MyApplicationProject
首先先 Actionbarsherlock 下載 Lib下來
Github: https://github.com/JakeWharton/ActionBarSherlock
Website: http://actionbarsherlock.com/
接著再裡面找他的Lib /actionbarsherlock
然後再把它拉到你的專案下面,我Actionbarsherlock是放桌面
至於你的路徑在哪就在哪邊去建立
mkdir libraries cp -r ~/Desktop/JakeWharton-ActionBarSherlock-071a61c/actionbarsherlock libraries/
在MyApplicationProject目錄下的 settings.gradle 加入這一行
include ':libraries:actionbarsherlock'
在到MyApplicationProject/MyApplication/build.gradle 裡面的 dependencies {...}加入下面
*在這裡我們把
因為Actionbarsherlock本身就有引入這個jar就可以拿掉
dependencies { compile project(':libraries:actionbarsherlock') }
接著再 MyApplicationProject/libraries/actionbarsherlock/ 新增 build.gradle
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android-library' dependencies { compile files('libs/android-support-v4.jar') compile files('libs/android-support-v13.jar') } android { compileSdkVersion 17 buildToolsVersion "17" defaultConfig { minSdkVersion 7 targetSdkVersion 16 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('tests') } }
在MyApplicationProject目錄下key
./gradlew build
如果你是Windows,就是下面
./gradlew.bat build
然後他就會開始跑跑跑,跑完就完成!
參考資料:http://rsproglog.blogspot.tw/2013/05/gradle-new-android-build-system_21.html