Consider the following project structure:
MainProject -.idea -.grandle -src -SubProject --libs
I downloaded .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 the lib folder in SubProject, and then put the .jar in it.
In Android Studio, I right-clicked on the library and selected "Add as library ...". with level: "Project library" and module: "Subproject".
Rxjava uses the package name "rx". I have specific code that imports this package:
import rx.Observable; import rx.Observer; import rx.Subscription; import rx.subscriptions.Subscriptions;
When creating a project, the following error occurs:
Gradle: package rx does not exist Gradle: package rx.util.functions does not exist Gradle: cannot find symbol class Action1 ...
I found that to add a line to SubProject / build.grandle it is required:
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 he throws:
Gradle: A problem occurred evaluating project ':SubProject'. > The description libs/rxjava-core-0.16.0-sources.jar is invalid
I tried moving the .jar around the project structure, but so far no luck.
How to add a third-party library to a project? Is it normal that I created the "libs" folder myself?
source share