Code Bug Fix: How to generate jar in Android Studio for backendless service?

Original Source Link

Im trying to make a JAR for backendless service by using Android Studio. I’m using Android Studio and this topic which I am following How to make a .jar out from an Android Studio project

When I generate JAR while backendless library included I got a failure. Error message below

                FAILURE: Build failed with an exception.

                    * What went wrong:
            Execution failed for task ':app:lint'.
                    > Lint found errors in the project; aborting build.

            Fix the issues identified by lint, or add the following to your build script to proceed with errors:
      ...
            android {
                lintOptions {
                    abortOnError false
                }
            }
      ...

            Errors found:

            C:UsersPublic.gradlecachesmodules-2files-2.1com.backendlessbackendless5.7.16edaf9b7b4a7228b1924efde6e9f804cdd14b6c9backendless-5.7.1.jar: Error: Invalid package reference in com.backendless:backendless; not included in Android: javax.jms. Referenced from weborb.messaging.v3.Subscriber. [InvalidPackage]
            C:UsersPublic.gradlecachesmodules-2files-2.1com.backendlessbackendless5.7.16edaf9b7b4a7228b1924efde6e9f804cdd14b6c9backendless-5.7.1.jar: Error: Invalid package reference in com.backendless:backendless; not included in Android: javax.servlet.http. Referenced from weborb.messaging.v3.StreamingSubscriber. [InvalidPackage]
            C:UsersPublic.gradlecachesmodules-2files-2.1com.backendlessbackendless5.7.16edaf9b7b4a7228b1924efde6e9f804cdd14b6c9backendless-5.7.1.jar: Error: Invalid package reference in com.backendless:backendless; not included in Android: javax.servlet. Referenced from weborb.messaging.v3.StreamingSubscriber. [InvalidPackage]

But when I follow the hint from error and include abortOnError false and skip the error. I don’t have any jar file in LIB folder

That’s my Gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.rwapp.apiservice"
        minSdkVersion 17
        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'
        }
    }
    //    lintOptions {
    //        abortOnError false
    //    }
}

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

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.backendless:backendless:5.7.1'

//    implementation group: 'com.backendless', name: 'backendless', version: '5.0.+'

}

task deleteJar(type: Delete) {
    delete 'libs/jars/logmanagementlib.jar'
}

task createJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('libs/jars/')
    include('classes.jar')
    rename('classes.jar', 'logmanagementlib.jar')
}

createJar.dependsOn(deleteJar, build)

For others who have a similar problem, the root cause was that there were two different versions of the same dependency included into the project.

Tagged : / /