android studio中導入xUtils和xUtils3開源庫

前題:xUtils和xUtils3是不一樣的,xUtils3是xUtils的升級版,下面是分別導入的方法

導入xUtils

在github上下載下來xUtils,發現那個library不能被android studio識別爲庫文件,不能直接用import Module方法導入,因爲少了build.gradle文件吧。所以我直接將下載下文件中的的xUtils-2.6.14.jar 這個jar包複製到對應Module的libs庫中,然後右鍵Add As library即可

1

1

導入xUtils3開源庫

1

1. 將xUtils的build.gradle文件中的版本號改成你自己項目的

1

2. 項目會出現如下圖所示錯誤

2

3. 將下面兩句內容加添加到Project中的build.gradle中的dependencies中

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

3

思路:可以先將xUtils做爲一個android項目在android studio中打開,查看這個項目的build.gradle文件,然後按着修改自己項目的build文件即可。期間xUtils3Sample的build.gradle可能會報錯,下面的代碼中的compile後面的版本注意一下,不要弄錯。

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile project(':xutils')
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章