2017-03-04 146 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):禁用离线模式和文件同步显示在项目结构对话框中显示 –

相关问题