Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

class file for android.support.v4.widget.DrawerLayoutImpl not found on travis support-v4 21.0

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.

  • The tests failed with the same error when ran on the machine initially.
  • Tried by manually copying internal_impl-21.0.0.jar found inside the support-v4 aar file to our libs/ directory and the tests passed.
  • Manually installed 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.

like image 971
ragdroid Avatar asked Oct 21 '14 13:10

ragdroid


3 Answers

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.

like image 132
Tor Norbye Avatar answered Nov 10 '22 23:11

Tor Norbye


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")
like image 42
Aliya Avatar answered Nov 11 '22 00:11

Aliya


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.

like image 1
ragdroid Avatar answered Nov 10 '22 22:11

ragdroid