1)所有正在测试的设备/仿真器都禁用了动画.
2)我有一个@BeforeClass来构建我的Credentials对象.
3)我有一个在@Before中注册的IntenServiceIdlingResource和一个EventBusIdlingResource.
4)单击登录按钮时,IntentService将触发.在这种情况下,服务器(模拟服务器)返回500错误.该信息通过greenrobot的EventBus从IntentService发回UI,并显示Snackbar并显示错误消息.
这是测试的代码:
@Test
public void a_userNamePasswordTest() throws Exception {
// email input
ViewInteraction userNameView = onView(withId(R.id.email));
// verify it's on screen and enabled
userNameView.check(matches(isDisplayed())).check(matches(isEnabled()));
// set the username
userNameView.perform(scrollTo(), replaceText(credentials.username), closeSoftKeyboard());
// password input
ViewInteraction passwordView = onView(withId(R.id.password));
// verify it's on screen and enabled
passwordView.check(matches(isDisplayed())).check(matches(isEnabled()));
// set the password.
passwordView.perform(scrollTo(), replaceText(credentials.password), closeSoftKeyboard());
// sign in button
ViewInteraction signInButton = onView(withId(R.id.email_sign_in_button));
// verify the button
signInButton.check(matches(allOf(
isDisplayed(), isEnabled(), withText("Sign In"), withContentDescription("Sign In")
)));
// clickity click the …Run Code Online (Sandbox Code Playgroud) android android-support-library android-espresso android-snackbar
尝试使用ViewPager进行一些测试.
我想在标签之间滑动,我不想继续直到滑动完成.但似乎没有办法关闭视图寻呼机的动画(禁用开发人员选项下的所有动画).
因此,这总是会导致测试失败,因为视图寻呼机尚未完成动画,因此视图尚未完全显示:
// swipe left
onView(withId(R.id.viewpager)).check(matches(isDisplayed())).perform(swipeLeft());
// check to ensure that the next tab is completely visible.
onView(withId(R.id.next_tab)).check(matches(isCompletelyDisplayed()));
Run Code Online (Sandbox Code Playgroud)
是否有一种优雅的,甚至是推荐的方式来做到这一点,还是我不能在那里进行某种定时等待?
我基于ABI而不是密度分割我的应用程序,如下所示:
splits {
abi {
enable true
reset()
include 'x86', 'armeabi', 'armeabi-v7a', 'mips', 'arm64-v8a'
universalApk true
}
}
Run Code Online (Sandbox Code Playgroud)
我有多种口味和2种构建类型(调试和发布).我想把通用的apk文件放在面料测试版上,该文件包含适用于所有平台的原生库.据我所知,这是通过ext.betaDistributionApkFilePath属性支持的.
我可以在buildType级别或者在flavor级别定义它.问题是我需要构建类型和风格来获取我的变体 - 这样的事情:
android.applicationVariants.all { variant ->
variant.ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/app-${variant.productFlavors[0].name}-universal-${variant.buildType.name}.apk"
}
Run Code Online (Sandbox Code Playgroud)
要么
gradle.taskGraph.beforeTask { Task task ->
if(task.name ==~ /crashlyticsUploadDistribution.*/) {
System.out.println("task name: ${task.name}");
android.applicationVariants.all { variant ->
System.out.println("match: crashlyticsUploadDistribution${variant.name}");
if(task.name ==~ /(?i)crashlyticsUploadDistribution${variant.name}/){
ext.betaDistributionApkFilePath = "${buildDir}/outputs/apk/app-${variant.productFlavors[0].name}-universal-${variant.buildType.name}.apk"
System.out.println(ext.betaDistributionApkFilePath);
}
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这似乎不起作用 - 目前有没有办法做到这一点?
android crashlytics android-gradle-plugin crashlytics-beta crashlytics-android
我正在尝试更新我的Android O应用程序,并且这样做需要更新以支持库26.
我的compileSdkVersion是26,targetSdkVersion 26,buildToolsVersion 26.0.1,支持库版本是26.0.1,播放服务/ firebase消息是11.0.4.我正在使用Android Studio 3.0 b2和android gradle插件3.0.0-beta2.看来这个版本对支持库冲突更加敏感.
我必须手动排除支持依赖项以解决冲突,因为播放服务和firebase链接对旧版本的支持库:
implementation("com.google.android.gms:play-services-auth:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-identity:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-base:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.android.gms:play-services-analytics:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.firebase:firebase-messaging:$playServicesVersion",{
exclude group: 'com.android.support'
})
implementation("com.google.firebase:firebase-analytics:$playServicesVersion",{
exclude group: 'com.android.support'
})
Run Code Online (Sandbox Code Playgroud)
这修复了我的所有依赖冲突,除了一个.
Google Play服务/ Firebase需要使用google-services gradle插件来解析生成的.json文件,并在应用中包含必要的密钥/秘密.我的build.grade有一个buildcript块,如下所示:
buildscript {
repositories {
maven { url "https://maven.google.com" }
jcenter()
}
dependencies {
classpath "com.google.gms:google-services:3.1.0"
}
}
Run Code Online (Sandbox Code Playgroud)
在脚本的最后,我应用插件.随着apply和classpath被注释掉,一切都正确编译.但是,似乎google-services 3.1.0增加了对支持库版本25.2.0的依赖,而我无法弄清楚如何覆盖它.消息是:
- 出了什么问题:任务':app:preDevelopmentDebugBuild'执行失败.
Android依赖项"com.android.support:support-v4"具有不同版本的编译(25.2.0)和运行时(26.0.1)类路径.您应该通过DependencyResolution手动设置相同的版本
请注意,我甚至无法降级到支持库25.4.0,因为我得到了相同的错误(只需用25.4.0替换上面的消息中的26.0.1).唯一有效的版本是25.2.0
运行./gradlew app:dependencies包含类路径依赖项,给我这个:
compile - Compile dependencies for 'main' sources (deprecated: …Run Code Online (Sandbox Code Playgroud) android firebase google-play-services android-gradle-plugin android-8.0-oreo