We are trying to run tests on travis CI. We have a class which uses android.support.v4.widget.DrawerLayout
.
When we use android support v4 library
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
we donot get this error but on using
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
We get the error
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 even shows that it has downloaded and installed Android Support Library revision 21, but still the above error.
Update:
We tried to run tests on the VM set up by travis guys.
internal_impl-21.0.0.jar
found inside the support-v4
aar
file to our libs/
directory and the tests passed.Android SDK tools 23.0.5
on the VM and the tests passed.Our project .travis.yml
has the following lines:
- tools
- platform-tools
- build-tools-21.1.1
- android-21
- extra-android-support
- extra-android-m2repository
- extra-google-m2repository
Still the tests are failing on travis.
This sounds like a bug in travis. If it does not use Gradle to build everything but does some building on its own (which it sounds like, given that you have special YAML files listing dependencies), it needs to handle AAR file dependencies by not just including classes.jar, but jars under libs/ as well.
Manually adding the library to the server in build.gradle worked:
testCompile fileTree(dir: "${rootDir}/YourProject/build/intermediates/exploded-aar/com.android.support/support-v4/", include: "**/*.jar")
Edited Answer:
This issue is fixed by using the pre-compiled DrawerActions.java
class from the espresso-contrib
library. For setup instructions see the link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With