.aar文件與.jar文件的區(qū)別
兩者區(qū)別:
*.jar:只包含了class文件與清單文件,不包含資源文件,如圖片等所有res中的文件。
*.aar:包含所有資源,class以及res資源文件全部包含
Gradle 的一些基本依賴配置方式如下:
輸出 apk :apply plugin: 'com.android.application'
輸出 aar : apply plugin: 'com.android.library'
compile fileTree(dir: 'xxx', include: ['*.jar', "*.xxx"]):將某個目錄下所有符合擴(kuò)展名的文件作為依賴;
compile 'com.xx.xx:ProjectName:Version':配置Maven` 庫作為依賴;在 Maven 庫中心(http://search.maven.org/#search) 可以搜索自己想用的庫進(jìn)行依賴;
compile project(':AnotherModule'):配置另一個 Module 作為本 Module 的依賴,被依賴的 Module 必須被導(dǎo)入到當(dāng)前工程中;
compile files('xxx.jar'):配置某個 jar 包作為依賴。
以src/chrome/android/java/build.gradle為例:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', exclude: 'android-support-multidex.jar', include: '*.jar') //將libs目錄下的所有*.jar作為依賴, 除了android-support-multidex.jar
compile 'com.android.support:multidex:1.0.0' //使用Maven庫中的multidex作為依賴
compile project(':mediaplayer')
compile project(':web_contents_delegate_android')
compile project(':browser_I')
compile project(':chromium_gen')
compile project(':hostlib')
compile files('libs/decrawso.jar') //這幾行是沒用的
compile files('libs/qihoospeechrecognition.jar') //這幾行是沒用的
compile files('libs/QHStatAgent.jar') //這幾行是沒用的
compile files('libs/adsdk_0.1.16.1125.jar') //這幾行是沒用的
compile files('libs/andfix.jar') //這幾行是沒用的
compile files('libs/opensdk-release.jar') //這幾行是沒用的
compile files('libs/BluewareAgent.jar') //這幾行是沒用的
}
說明:
輸出的是apk文件, 輸出位置在:
src/chrome/android/java/build/outputs/apk/chrome-debug.apk依照第一條依賴規(guī)則, 根本沒必要寫, "http://這幾行是沒用的",
去掉后編譯也可以通過, 說明寫build.gradle的開發(fā)對gradle的依賴規(guī)則并沒有充分了解.
再以src/chrome/android/chromium_gen/build.gradle為例:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':base')
compile 'com.android.support:appcompat-v7:23.1.1' //使用Maven庫中的appcompat作為依賴
compile 'com.android.support:support-v13:23.1.1' //使用Maven庫中的support作為依賴
}
說明:
輸出的是aar文件, 輸出位置在:
src/chrome/android/chromium_gen/build/outputs/aar/chromium_gen-debug.aar
------DONE.-----------