Cannot resolve symbol 'AndroidJUnit4'

前端 未结 19 2268
别跟我提以往
别跟我提以往 2020-12-02 08:48

Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be

import android.support.test.runn         


        
19条回答
  •  醉话见心
    2020-12-02 09:35

    The same error occurred to me when I follow Google IOSched app and set up my project with three build types [debug,release,staging] where debug and release share the same source directory

    sourceSets {
        debug.java.srcDir 'src/debugRelease/java'
        release.java.srcDir 'src/debugRelease/java'
    }
    

    In this case, specify the testBuildType in your module-level build.gradle file and the project should now be able to resolve symbol 'AndroidJUnit4'.

    ...
    sourceSets {
        debug.java.srcDir 'src/debugRelease/java'
        release.java.srcDir 'src/debugRelease/java'
    }
    
    testBuildType "staging"
    ...
    

    Reference: https://github.com/google/iosched/blob/master/mobile/build.gradle

提交回复
热议问题