2016-12-17 34 views
0

我試圖用離子,所以我需要使用這個庫錯誤而進口在github上庫到Android的

我下載的zip文件,提取它放入我的項目的根目錄中的文件名爲子項目中(僅離子文件夾沒有其他兩個)然後在我的settings.gradle我加

include ':app',':subProject:ion' 

我給了一個錯誤,說書中有沒有有效的路徑,以便項目不能進行清洗。然後,我改變了它,並添加編譯語句的build.gradle

include ':app',':subProject' 

compile project(':subProject:ion') 

但是當我嘗試使用Ion.something它告訴我,它給了我一個錯誤,因爲它無法解析離子是什麼。我如何導入?我的方式做它是在互聯網上的解決方案,但它未能

這裏的時候,我得到了未知的符號錯誤我嘗試的代碼使用等

Ion.with(getApplicationContext()) 
       .load("http://www.example.com/abc/def/") 
       .setBodyParameter("identifier", "foo") 
       .setBodyParameter("email", "[email protected]") 
       .setBodyParameter("password", "[email protected]") 
       .asString() 
       .setCallback(new FutureCallback<String>() { 
        @Override 
        public void onCompleted(Exception e, String result) { 
         // Result 
        } 
       }); 
+0

你爲什麼下載並提取它。閱讀自述文件,使用Gradle。 https://github.com/koush/ion#gradle –

+0

只需使用'依賴項'編譯'com.koushikdutta.ion:ion'2. +' }' – Basi

+0

使用這個時應該將項目下載到主根? – Prethia

回答

2

讓您的生活更輕鬆,去你的build.grandle(模塊:應用程序),並在代碼里加入括號的依賴關係是這樣的:

apply plugin: 'com.android.application' 

android { 
// leave code here as it is 
} 

dependencies{ 
// other code here 
compile 'com.koushikdutta.ion:ion:2.+' 
} 

如果你想知道我的意見,你可以使用圖書館畢加索從GitHub簡單地增加編譯「com.squareup.picasso:畢加索:2.5 2.2' 。我給你鏈接檢查:HAPPY CODING

+0

我添加了依賴關係並清理了重建項目,但我仍然遇到同樣的錯誤。我是否也應該下載rar文件將其解壓並放到我的項目文件夾中的某個地方? – Prethia

+0

好吧,我得到了問題。我習慣在eclipse中這樣做,所以我認爲有一個自動導入 – Prethia