我们正尝试在Travis CI上运行测试。我们有一个使用android.support.v4.widget.DrawerLayout
的类。
当我们使用Android支持v4库时,在build.gradle
中:
targetSdkVersion: 19
`compile 'com.android.support:support-v4:20.0.0'`
.travis.yml
- build-tools-19.1.0
- android-19
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
我们没有遇到这个错误,但在使用 build.gradle
时出现了问题。targetSdkVersion: 21
com.android.support:support-v4:21.0.+
.travis.yml
- build-tools-21.0.1
- android-21
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
我们遇到了错误
private static class IdlingDrawerListener implements DrawerListener, IdlingResource {
^
class file for android.support.v4.widget.DrawerLayoutImpl not found
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:200: error: cannot find symbol
private ResourceCallback callback;
^
symbol: class ResourceCallback
location: class IdlingDrawerListener
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:255: error: cannot find symbol
public void registerIdleTransitionCallback(ResourceCallback callback) {
^
symbol: class ResourceCallback
location: class IdlingDrawerListener
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:153: error: method setDrawerListener in class DrawerLayout cannot be applied to given types;
drawer.setDrawerListener(IdlingDrawerListener.getInstance(existingListener));
^
required: DrawerListener
found: IdlingDrawerListener
reason: actual argument IdlingDrawerListener cannot be converted to DrawerListener by method invocation conversion
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:192: error: cannot find symbol
instance = new IdlingDrawerListener();
^
symbol: constructor IdlingDrawerListener()
location: class IdlingDrawerListener
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:193: error: method registerIdlingResources in class Espresso cannot be applied to given types;
Espresso.registerIdlingResources(instance);
^
required: IdlingResource[]
found: IdlingDrawerListener
reason: argument type IdlingDrawerListener does not conform to vararg element type IdlingResource
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:205: error: non-static variable this cannot be referenced from a static context
this.parentListener = parentListener;
^
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:205: error: cannot find symbol
this.parentListener = parentListener;
^
symbol: variable parentListener
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:208: error: method does not override or implement a method from a supertype
@Override
^
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:215: error: method does not override or implement a method from a supertype
@Override
^
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:256: error: non-static variable this cannot be referenced from a static context
this.callback = callback;
^
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:256: error: cannot find symbol
this.callback = callback;
^
symbol: variable callback
/home/travis/build/something/sample/src/test/java/com/abc/somesample/espresso/DrawerActions.java:254: error: method does not override or implement a method from a supertype
@Override
^
即使Travis显示已下载并安装了Android Support Library修订版21,但仍出现上述错误。
更新:
我们尝试在travis提供的VM上运行测试。
- 当最初在机器上运行时,测试以相同的错误失败。
- 通过手动复制
support-v4
aar
文件中找到的internal_impl-21.0.0.jar
到我们的libs/
目录中进行尝试,测试通过了。 - 在VM上手动安装
Android SDK工具23.0.5
后,测试通过。
我们的项目.travis.yml
中有以下几行:
- 工具
- 平台工具
- 构建工具21.1.1
- Android-21
- extra-android-support
- extra-android-m2repository
- extra-google-m2repository
即使如此,测试仍在Travis上失败。