Android Studio无法正确地将我重定向到API源.当我点击任何函数时,它会反编译.class文件字节码,而不是从sdk/sources树访问正确的文件.
点击"下载"和"刷新"选项什么都不做.这对于实现监听器来说尤其令人讨厌,因为它从文档中生成函数"不带变量"的标题(即var1,var2等).我已将complie和目标SDK设置为23.我尝试重新安装SDK工具,从canary通道更新AS,使缓存无效但到目前为止没有任何帮助.我切换到API 21,它工作正常.我错过了什么?
编辑 我已经安装了API 23(SDK平台,工具,文档,资源),所以如果你想进行downvote,请发表评论.
编辑 我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.myapp.app"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile project(':volley')
compile 'com.jakewharton:butterknife:7.0.1'
}
Run Code Online (Sandbox Code Playgroud)
您可以在下面找到具有相同API 23设置和相同行为的空白项目(没有第三方库)的gradle输出.
Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Configuration on demand is an incubating feature.
Incremental …
Run Code Online (Sandbox Code Playgroud) 当背景颜色具有一定透明度时, Android Jetpack composeCard
会在卡片周围绘制边框。这是它在 AS 中的样子:
但这是它在应用程序中的样子:
如果我将背景设置为纯色,它就可以工作,但默认情况下backgroundColor
是来自材质的表面颜色(在我的应用程序中val white850 = Color(0xD9FFFFFF)
),它看起来像上图所示。
@Composable
fun TraitCard(trait: Trait) {
Card(
shape = MaterialTheme.shapes.small,
modifier = Modifier.size(width = 192.dp, height = 56.dp)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
Icon(
imageVector = Icons.Rounded.ChildFriendly,
contentDescription = "",
modifier = Modifier
.fillMaxHeight()
.background(color = MaterialTheme.colors.background)
.aspectRatio(1f)
.padding(8.dp),
tint = MaterialTheme.colors.onBackground
)
Text(
text = trait.name,
style = MaterialTheme.typography.h3,
modifier = Modifier.padding(horizontal = 16.dp),
)
}
} …
Run Code Online (Sandbox Code Playgroud) 我无法UiObject2
在 androidTest 中使用 UiAutomator 找到元素 ( )。我获得了 UiDevice 实例并尝试使用以下命令查找对象:
MY_UI_DEVICE.findObject(By.res(CURRENT_PACKAGE, id));
Run Code Online (Sandbox Code Playgroud)
CURRENT_PACKAGE
是我的应用程序的包MY_UI_DEVICE.getCurrentPackageName()
。我也尝试过这个:
MY_UI_DEVICE.wait(Until.findObject(By.res(CURRENT_PACKAGE, id)), 10000);
Run Code Online (Sandbox Code Playgroud)
我可以看到应用程序在右侧屏幕上等待 10 秒(所需的对象仍然存在),但超时后它无法找到它并且测试失败。它在模拟器 (API 23) 上总是失败,但在真实设备 (API 25) 上很少能正常工作。
当我调试代码时,我可以看到,我可以通过手动调用getChild(index)
方法序列来获取正确的元素AccessibilityNodeInfo
,但在运行时,即使应用程序在我期望的特定元素的正确屏幕上等待,它仍然会失败。
我正在使用不同的 UiDevice 功能,但没有任何帮助,而且我没有想法,所以任何帮助将不胜感激。
android ×2