Ali
Ali

Reputation: 9994

Import RxAndroid to Android Studio

I am trying to import RxAndroid to Android Studio 1.0.2. As soon as I import project from Gradle using default gradle wrapper, I face with following error:

enter image description here

Is there anyone who know the reason?

Upvotes: 1

Views: 4033

Answers (2)

Sergii Pechenizkyi
Sergii Pechenizkyi

Reputation: 22232

AndroidStudio is a special version of IntelliJ IDEA tailored to work withandroid-gradle-plugin. AndroidStudio is supposed to be used for building android apps and android libraries.

RxAndroid is java library project built with Nebula's gradle-rxjava-project-plugin which is not compatible with android-gradle-plugin. Therefore can't be opened at AndroidStudio. You can use IntelliJ for now.

See for reference: https://github.com/ReactiveX/RxAndroid/pull/81 , https://github.com/ReactiveX/RxAndroid/issues/74

Upvotes: 0

bjiang
bjiang

Reputation: 6078

I just put compile 'io.reactivex:rxandroid:0.24.0' in the gradle dependencies and it works fine.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'io.reactivex:rxandroid:0.24.0'
}

your build.gradle file under the app should be some like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    defaultConfig {
        applicationId "com.map_ex"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'io.reactivex:rxandroid:0.24.0'
}

and then you can use classes from RxAndroid

Upvotes: 1

Related Questions