2017-03-04 147 views
0

當我同步我的android studio項目時,得到 錯誤:(9,0)找不到方法編譯()爲參數[io.reactivex:rxandroid:1.2.1]上類型的對象org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler錯誤:(9,0)找不到方法compile()參數[io.reactivex:rxandroid:1.2.1]

我的build.gradle文件低於

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 

    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 
     compile 'io.reactivex:rxandroid:1.2.1' 
     compile 'io.reactivex:rxjava:1.1.9' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 

    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 

    delete rootProject.buildDir 
} 

回答

1

您在錯誤的部分稱此庫。有兩種build.gradle文件。欲瞭解更多信息build.gradle

爲了解決這個問題,你應該補充必需的依賴到build.gradle在模塊級,準確應用程序\的build.gradle

從根源消除您的依賴 'build.gradle'並將它們粘貼到app \ build.gradle中。

android { 
    compileSdkVersion // YOURS 
    buildToolsVersion // YOURS 
    ........... 
     } 
    dependencies { 
      compile 'io.reactivex:rxandroid:1.2.1' 
      compile 'io.reactivex:rxjava:1.1.9' 
    } 

FYI

這是更好地使用最新版本,

compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 
compile 'io.reactivex.rxjava2:rxjava:2.0.1' 
+0

當我添加這的build.gradle模塊級別它被錯誤無法解析:io.reactivex:rxjava :1.1.9 –

+0

@DipuKumar什麼錯誤? –

+1

錯誤(29,13)和錯誤(28,13):禁用離線模式和文件同步顯示在項目結構對話框中顯示 –

相關問題