java – 在导入中无法识别的AndroidTestCompile依赖项
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 在导入中无法识别的AndroidTestCompile依赖项,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2795字,纯文字阅读大概需要4分钟。
内容图文
![java – 在导入中无法识别的AndroidTestCompile依赖项](/upload/InfoBanner/zyjiaocheng/809/90fe9694e5ab466b900a39b80bdebfe0.jpg)
实际上,我的项目有单元测试.所有这些都在/ src / test / java /中配置.最近我需要在/ src / androidTest / java中添加检测测试.为此,我在build.gradle中添加了espresso依赖项.
dependencies {
compile files('libs/pixlui-1-0-5.jar')
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
transitive = true
}
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services-maps:7.3.0'
compile 'com.google.android.gms:play-services-location:7.3.0'
compile 'com.google.android.gms:play-services-gcm:7.3.0'
compile 'com.loopj.android:android-async-http:1.4.5'
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:20.+'
compile 'ch.acra:acra:4.5.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.squareup.picasso:picasso:2.3.4'
provided 'com.squareup.dagger:dagger-compiler:1.2.+'
compile 'com.squareup.dagger:dagger:1.2.+'
compile 'com.google.guava:guava:15.0'
compile 'com.facebook.android:facebook-android-sdk:3.23.0'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
compile 'com.google.maps.android:android-maps-utils:0.3+'
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude module: 'support-annotations'
}
}
之后我选择了Build Variants – >测试工件 – > Android Instrumentation测试.
但是当我开始编码时,没有任何依赖项被识别:
“无法解析onView上的符号”,“无法解析符号ViewInteraction”等…
这是我的活动测试:
import android.support.test.espresso.Espresso.onView;
import android.test.ActivityInstrumentationTestCase2;
import com.wiffinity.easyaccess.R;
/**
* Created by Javier on 05/06/2015.
*/
public class EntryActivityTest extends ActivityInstrumentationTestCase2<EntryActivity> {
public EntryActivityTest() {
super(EntryActivity.class);
}
@Override
protected void setUp() throws Exception
{
super.setUp();
getActivity();
}
public void testLoginButtonClicked(){
onView();
ViewInteraction entryBtn;
entryBtn = onView(withId(R.id.entry_button));
entryBtn.performClick();
}
}
为什么Android Studio 1.2无法解决这些依赖关系?我忘了配置什么吗?
解决方法:
您可能需要重建项目.
在Android Studio中:
构建 – >重建项目.
如果它没有帮助运行以下gradle任务(假设你有一个包装器,你的模块名称是“app”):
./gradlew app:dependencies
并确保您的androidTest任务包含espresso依赖项.
更新:
有时重建项目并不能解决问题,唯一的解决方案是通过执行gradle assembleAndroidTest任务手动重建测试apk.
内容总结
以上是互联网集市为您收集整理的java – 在导入中无法识别的AndroidTestCompile依赖项全部内容,希望文章能够帮你解决java – 在导入中无法识别的AndroidTestCompile依赖项所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。