2016-12-30 12 views
2

PluralsightのStart Developing for Androidコースをフォローしています。テストを追加しようとしています。命令はbuild.gradleファイルにandroidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'を追加すると言う:このIntelliJのをやった後方法を見つけることができません。

// 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.1' 

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

allprojects { 
    repositories { 
    jcenter() 
    } 

    dependencies { 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
    } 
} 

Gradleのファイルが変更されたとして、それが再び同期する必要があることを私に伝えます。私はそれを行うとき、私は次のエラーを取得するのに:

エラー:

15:17 Gradle sync failed: Could not find method androidTestCompile() for arguments [com.android.support.test.espresso:espresso-core:2.2.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 
      Consult IDE log for more details (Help | Show Log) 

NB:私はバージョン2.2.12.2.2を試してみました。

ここでは何が起こっていますか?

おかげ

答えて

1

依存性appモジュールのbuild.gradleに添加されるべきです。あなたの場合、親プロジェクトのbuild.gradleを追加しました。

+0

ありがとうAndy、私は今、別のエラーが発生しているので、フォローアップの質問があります[ここ](http://stackoverflow.com/questions/41399724/cannot-find-androidtestcompile-on-android-build )。あなたもそれを見ることができるでしょうか?ありがとう。 – BanksySan

関連する問題