1

I'm trying to build .Jar file out of Android Library Project using gradle with jar dependencies

what should i do ?

My build.gradle file

apply plugin: 'com.android.library'

    android {
        compileSdkVersion 26
        buildToolsVersion '26.0.2'
    
        lintOptions {
            abortOnError false
        }
        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
        }
        flavorDimensions "default"
        productFlavors {
            dev {
               
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    task jarTask(type: Jar) {

        baseName="my-library"
        from 'src/main/java'
    }

    task createJarWithDependencies(type: Jar) {

        baseName = "my-library"
    
        from {
            configurations.compile.collect {
                it.isDirectory() ? it : zipTree(it)
            }
        }
    }
    
    configurations {
        jarConfiguration
    }
    
    artifacts {
        jarConfiguration jarTask
    }
    //this are library that i want to include in jar 
    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation files('libs/converter-gson-2.3.0.jar')
        implementation files('libs/converter-simplexml-2.3.0.jar')
        implementation files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
        implementation files('libs/logging-interceptor-3.9.1.jar')
        implementation files('libs/okhttp-3.9.1.jar')
        implementation files('libs/okio-1.13.0.jar')
        implementation files('libs/retrofit-2.3.0.jar')
        implementation files('libs/simple-xml-2.7.1.jar')
    }

please any one tell me how to create jar with jar dependencies and java class that i made in android library ?

Community
  • 1
  • 1
Mario
  • 11
  • 2
  • ** Process: com.veritaspay.webservice, PID: 20678 java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/logging/HttpLoggingInterceptor; ** i got this error because of the dependencies not included in the jar that generated – Mario Dec 20 '17 at 11:44
  • How can i include the jar dependencies ? – Mario Dec 20 '17 at 12:06

0 Answers0