0

I'm implementing my android-module from github using jitpack, and i want to do compileOnly instead of implementation

but when I use the code compileOnly it shows me that the complieOnly not supported


I'm creating an application to read plugins

all application and plugins depends on a library I have created

the plugin well have a classes that extends a class on the library and the application should read those classes and invoke methods on them

as you know the application SHOULD contains the library classes and the plugin SHOULDN'T, else we'll face a doublecated classes exception or/and class cast exception

I worked on it and it worked perfectly while the application and the plugins all compiled the library using an aar file of it

but when i decied to move on to github implementation it worked for the application but not for the plugin and the issue is i can't tell gradle to do compileOnly to the library


plugin's module build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"

    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }

}

dependencies {
    compileOnly 'com.github.LSaferSE:Services-Android:master'//<--- here is the problem

    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    testImplementation 'junit:junit:4.13-beta-3'
    androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
}

plugin's project build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

expecting a build success but faced :

ERROR: Android dependency 'com.github.LSaferSE:Services-Android:master' is set to compileOnly/provided which is not supported

one more thing, I tried using api instead but I'm not sure what's the diffrent from implementation, but I'm sure it'll pack library classes in the plugin's apk, so please tell me if you know it'll not effect while loading the apk using DexClassLoader (fyi it'll effect using implementation)

LSafer
  • 344
  • 3
  • 7
  • Have you tried replacing the `compileOnly` with `provided`. As per dependency [docs](https://developer.android.com/studio/build/dependencies), the `compileOnly` behaves just like `provided` (which is now deprecated), but you might have been using the older version of build tool. – Igor Jul 23 '19 at 19:32
  • yeah I tried, but i got a deperecation warning :) – LSafer Jul 23 '19 at 19:40
  • also this error (the same error) `Android dependency 'com.github.LSaferSE:Services-Android:master' is set to compileOnly/provided which is not supported` – LSafer Jul 23 '19 at 19:42
  • at the moment I'm using internal aar file and it's working good, but the problem is javadoc well not be included while writing the code. – LSafer Aug 05 '19 at 10:57

0 Answers0