是否有可能使用gradle来生成依赖于什么的树?
我有一个项目,并希望找出所有的依赖项,所以我可以通过前向声明等来修剪它.
RelativeLayout layout =(RelativeLayout)findViewById(R.id.background);
layout.setBackgroundResource(R.drawable.ready);
Run Code Online (Sandbox Code Playgroud)
这是最好的方法吗?
Espresso声称没有必要Thread.sleep();,但我的代码不起作用,除非我包含它.我正在连接到IP.连接时,会显示进度对话框.我需要sleep等待对话框解散.这是我使用它的测试片段:
IP.enterIP(); // fills out an IP dialog (this is done with espresso)
//progress dialog is now shown
Thread.sleep(1500);
onView(withId(R.id.button).perform(click());
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用和不使用此代码,Thread.sleep();但它说不R.id.Button存在.我能让它发挥作用的唯一方法就是睡觉.
此外,我尝试用Thread.sleep();类似的东西替换,getInstrumentation().waitForIdleSync();但仍然没有运气.
这是唯一的方法吗?或者我错过了什么?
提前致谢.
我正在用python挑战来编写ruby中的代码,特别是这个.它在页面源中包含一个非常长的字符串,带有特殊字符.我试图找到一种方法来删除它们/检查字母字符.
我尝试使用扫描方法,但我想我可能不会正确使用它.我也尝试过delete!:
a = "PAGE SOURCE CODE PASTED HERE"
a.delete! "!", "@" #and so on with special chars, does not work(?)
a
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
谢谢
我正在尝试检查Espresso是否显示视图.这是一些伪代码来显示我正在尝试的内容:
if (!Espresso.onView(withId(R.id.someID)).check(doesNotExist()){
// then do something
} else {
// do nothing, or what have you
}
Run Code Online (Sandbox Code Playgroud)
但我的问题是.check(doesNotExist())不返回布尔值.这只是一个断言.使用UiAutomator,我能够做到这样的事情:
if (UiAutomator.getbyId(SomeId).exists()){
.....
}
Run Code Online (Sandbox Code Playgroud) 我试图使用Espresso点击列表视图中的文本.我知道他们有这个指南,但我看不到如何通过查找文本来完成这项工作.这就是我尝试过的
Run Code Online (Sandbox Code Playgroud)Espresso.onData(Matchers.allOf(Matchers.is(Matchers.instanceOf(ListView.class)), Matchers.hasToString(Matchers.startsWith("ASDF")))).perform(ViewActions.click());
正如所料,这不起作用.错误表示层次结构中没有视图.有谁知道如何选择一个字符串?("ASDF"在这种情况下)提前谢谢.
我收到错误:
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException:'可从类中分配:class android.widget.AdapterView'匹配层次结构中的多个视图.
有了这段代码
Run Code Online (Sandbox Code Playgroud)onData(hasToString(startsWith("ASDF"))).inAdapterView(withContentDescription("MapList")).perform(click());
我收到这个错误
com.google.android.apps.common.testing.ui.espresso.PerformException:在视图'上执行'加载适配器数据'时出错,内容描述为:"MapList"'.
引起:java.lang.RuntimeException:找不到匹配的数据:asString(以"ASDF"开头的字符串)
昂达(任何()).inAdapterView(withContentDescription( "降序")).atPosition(X).perform(点击())
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.m.e"
android:versionCode="5"
android:versionName="3.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.m.e"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action
android:name="android.intent.action.MAIN"
/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.m.e"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action
android:name="android.intent.action.first"
/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
.....
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
错误:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.m.e/.Splash }
Error type 3
Error: Activity class {com.m.e/com.m.e.Splash} does not exist.
Run Code Online (Sandbox Code Playgroud)
注意: .Splash 确实存在.
这是在我添加时开始的google-api-services-calendar.我在尝试构建时收到此错误:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.transform.api.TransformException: java.util.zip.ZipException:
duplicate entry: com/google/common/annotations/Beta.class
Run Code Online (Sandbox Code Playgroud)
这是运行时输出的一部分./gradlew app:dependencies:
compile - Classpath for compiling the main sources.
+--- com.google.android.gms:play-services-measurement:8.1.0
| +--- com.google.android.gms:play-services-base:8.1.0
| | \--- com.google.android.gms:play-services-basement:8.1.0
| | \--- com.android.support:support-v4:22.2.0 -> 23.0.1
| | \--- com.android.support:support-annotations:23.0.1
| \--- com.google.android.gms:play-services-analytics:8.1.0
| +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| \--- com.google.android.gms:play-services-ads:8.1.0
| +--- com.google.android.gms:play-services-basement:8.1.0 (*)
| \--- com.google.android.gms:play-services-appindexing:8.1.0
| \--- com.google.android.gms:play-services-basement:8.1.0 (*)
+--- com.google.dagger:dagger:2.0
| \--- javax.inject:javax.inject:1
+--- com.google.android.gms:play-services-identity:8.1.0
| \--- com.google.android.gms:play-services-base:8.1.0 (*)
+--- com.google.android.gms:play-services-plus:8.1.0
| \--- …Run Code Online (Sandbox Code Playgroud) 我知道Espresso可以按照UiAutomator的方式点击边界.(x和y坐标)我已经阅读了文档,但我似乎无法找到它.任何帮助表示赞赏.谢谢
编辑
我找到了这个链接,但没有示例如何使用它,我主要关心的是它UiController是如何使用它.
我正在构建一个使用时间的应用程序.我决定使用Joda时间.我正在尝试将joda时间添加到我的应用程序中.我没有将.jar文件添加到库中的经验.我按照这些步骤(见底部),或者我想.我的项目没有显示任何错误,但是当我运行一个简单的测试时:DateTime test = new DateTime();我收到一个强制关闭并出现以下错误:
Could not find class 'org.joda.time.DateTime', referenced from method xxxx
java.lang.NoClassDefFoundError: org.joda.time.DateTime
Run Code Online (Sandbox Code Playgroud)
这些是我遵循的步骤:
New -> Folder -> libs. 注意:我没有这样做,因为我已经有了一个名为的文件夹libsjoda-time-2.1.jar到新创建的libs文件夹中.Properties -> Java Build Path -> Libraries -> Add Jars -> joda-time-2.1.jar.现在您可以使用以下代码进行测试:
DateTime test = new DateTime();
Run Code Online (Sandbox Code Playgroud)
导入后:
import org.joda.time.DateTime;
Run Code Online (Sandbox Code Playgroud) android ×8
java ×4
background ×1
dependencies ×1
drawable ×1
duplicates ×1
gradle ×1
jodatime ×1
libs ×1
ruby ×1
testing ×1