stepango / aar2jar

Gradle plugin which will help you to add Aar dependencies into your java|kotlin modules
30 stars 10 forks source link

Unresolved reference when adding dependency using compileOnlyAar #2

Closed rAseri closed 5 years ago

rAseri commented 5 years ago

Thanks for the plugin!

I try to use this plugin to add rxAndroid aar dependency to my pure Kotlin gradle module. This is a build.gradle file of my Kotlin module:

plugins {
    id 'kotlin'
    id 'kotlin-kapt'
    id 'com.stepango.aar2jar' version "0.4"
}

dependencies {
    def dependencies = rootProject.ext.dependencies

    // Core app modules.
    implementation project(':core-di')

    // 3rd-party libs.
    implementation dependencies.kotlin
    implementation dependencies.rxJava
    compileOnlyAar dependencies.rxAndroid
    compileOnly androidJar

    // Kotlin annotation processors.
    kapt dependencies.daggerCompiler

    // Test libs.
    testImplementation dependencies.junit
}

My project builds successfully, but there is a dependency resolving issue when I try to import the library class:

// Unresolved reference here
import io.reactivex.android.schedulers.AndroidSchedulers

Could you explain what's the problem and how to handle this issue?

DmitriyG1 commented 5 years ago

Same error. I tried to use it through "compileOnlyAar" and "implementationAar"

stepango commented 5 years ago

Will be fixed next release. Workaround for now is

plugins {
    id 'kotlin'
    id 'idea'
    id 'com.stepango.aar2jar' version "0.4"
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    compileOnly androidJar
    compileOnlyAar "androidx.lifecycle:lifecycle-extensions:2.0.0"
    compileOnlyAar "androidx.lifecycle:lifecycle-livedata-core:2.0.0"
    compileOnlyAar 'androidx.appcompat:appcompat:1.0.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

afterEvaluate {
    idea {
        module {
            scopes.forEach { name, map ->
                map.plus += [configurations.compileOnlyAar]
            }
        }
    }
}
stepango commented 5 years ago

Fixed in v0.5 by https://github.com/stepango/aar2jar/commit/fc4d026e17b14c2e02a1dfb89a46dce623f0a6f6