I've seen partial answers to similiar issues but never one that actually solved the problem. I've boiled this down to a minimal app to demonstrate the issue.
I'm using the most current version of Android Studio (V2.2.1) I have the following SDK's installed:
- Android SDK Tools v25.1.6
- Android SDK Platform-tools v23.1
- Android SDK Build-tools v23.0.3
Android Support repository v32
- Create new Android app using wizard
Updated build.gradle (app) per: https://developer.android.com/training/testing/start/index.html#config-instrumented-tests
Added under defaultConfig:
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Added under dependencies
- androidTestCompile 'com.android.support:support-annotations:23.0.1' <-- Changed to 23.4.0 to match newly generated app
- androidTestCompile 'com.android.support.test:runner:0.4.1'
- androidTestCompile 'com.android.support.test:rules:0.4.1'
- androidTestCompile 'com.android.support:support-annotations:23.0.1' <-- Changed to 23.4.0 to match newly generated app
Did project sync to sync Gradle
Under the "test" package add new test file - ExampleIntegrationTest.java (right next to ExampleUnitTest.java)
In the new file, created integration test per: https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public interface ExampleIntegrationTest {
}
This is where the problem comes up - cannot resolve symbol AndroidJUnit4 On the line: import android.support.test.runner.AndroidJUnit4;
If I type the import statement I can use the popup suggestions:
- import android. - It shows "support as option"
- import android.support. - It shows "test" as an option
- import android.support.test. - Now it only shows "rule" as a option
After I create the app I make sure it's using the "debug" variant
This is pretty cut and dry. As far as I can tell this should work,, but the support library for some reason isn't getting imported correctly.