use*_*170 4 android integration-testing compiler-errors undefined-symbol android-studio
我已经看到过类似问题的部分答案,但从未真正解决过这个问题。我将其简化为一个最小的应用程序以演示该问题。
我正在使用最新版本的Android Studio(V2.2.1),并且安装了以下SDK:
Android支持存储库v32
每个更新了build.gradle(app):https : //developer.android.com/training/testing/start/index.html#config-instrumented-tests
在defaultConfig下添加:
在依赖项下添加
项目是否已同步以同步Gradle
在“测试”包下,添加新的测试文件-ExampleIntegrationTest.java(在ExampleUnitTest.java旁边)
在新文件中,根据以下网址创建集成测试: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 {
}
Run Code Online (Sandbox Code Playgroud)
这就是问题所在-无法解析符号AndroidJUnit4在线上:import android.support.test.runner.AndroidJUnit4;
如果输入import语句,我可以使用弹出建议:
-导入android。-显示“支持作为选项”
-导入android.support。-显示“测试”作为选项
-导入android.support.test。-现在仅显示“规则”作为选项
创建应用后,请确保使用的是“ debug”变体
这是很干的。据我所知,这应该可行,但是由于某种原因,支持库无法正确导入。
通过将测试添加到
或者,当您创建测试类时,通过在“项目”树的“ Android Instrumentation测试”选项卡中选择新类来添加测试
| 归档时间: |
|
| 查看次数: |
4574 次 |
| 最近记录: |