Android Studio adding rxjava library

android, java, rx-java

Solution

you could just try adding:

`compile 'com.netflix.rxjava:rxjava-android:0.16.1'`

and dont forget to click "Sync Project With Gradle Files" button.

Problem

Consider following project structure: ``` MainProject -.idea -.grandle -src -SubProject --libs //I created this folder manually ---rxjava-core-0.16.0-sources.jar --src ---main //+ all the sources --build.grandle --SubProject.iml -build.grandle -//other files ``` I downloaded the .jar from http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.netflix.rxjava%22%20AND%20a%3A%22rxjava-core%22 (sources.jar) - but I also tried others Then I created lib folder in the SubProject and then put the .jar to it. In Android Studio I rightclicked on the library and selected "Add as Library..." with level: "Project Library" and module: "SubProject". The rxjava uses package name "rx".I have some code implemented that imports this package: ``` import rx.Observable; import rx.Observer; import rx.Subscription; import rx.subscriptions.Subscriptions; ``` When building the project following error occure: ``` Gradle: package rx does not exist Gradle: package rx.util.functions does not exist Gradle: cannot find symbol class Action1 ... ``` I found that it is required to put a line to SubProject/build.grandle: ``` dependencies { compile 'libs/rxjava-core-0.16.0-sources.jar' //added line compile 'com.android.support:support-v4:19.0.0' compile 'com.android.support:appcompat-v7:19.0.0' } ``` but then it throws: ``` Gradle: A problem occurred evaluating project ':SubProject'. > The description libs/rxjava-core-0.16.0-sources.jar is invalid ``` I tried to moving the .jar around the project structure but so far no luck. How do I properly add a 3rd party library to the project? Is it ok that I created the "libs" folder myself?

Original source

Related problems