Arvind Chourasiya
Arvind Chourasiya

Reputation: 17412

Is there any way to get Jar files of android library with all dependencies using Android Studio

I am working on Salesforce Chatbot development for mobile applications. I have to develop it on xamarin(.Net). For that I need to have .Net libraries but those are doesn't seem to available.

Alternate way is to get .jar files of those Android libraries, add in .Net project and use it for development.

I am looking jar file for below configuration

   allprojects {
        repositories {
            google()
            jcenter()
            maven {
                url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release'
            }
        }
    }

   implementation 'com.salesforce.service:chat-ui:4.3.2'

I found above information here developer.salesforce.com/docs. I am unable to download .jar files for above configuration on internet.

Than I tried to develop sample project using above libraries in android studio and get .jar files from it. I have made the project. I want to get .jar files.

I have two question now

  1. How to download .jar files for above configuration from internet OR
  2. How can I download .jar files from android studio from sample project I created

Edit 1:

Below screenshot of ChatUIConfiguration from C# .dll, there is no create method. While create there for Android public static ChatUIConfiguration create. ChatUIConfiguration has 278 lines of code in android file and C# has only 100 lines. Am I missing any dependency or I need to add multiple jars from dependency folder?

enter image description here

Upvotes: 0

Views: 1325

Answers (1)

Stephan Schlecht
Stephan Schlecht

Reputation: 27106

After creating your sample project, you can get the .aar dependencies in Gradle based on this fine answer:

Add the following to the build.gradle file:

configurations {
    customConfig.extendsFrom implementation
}

task copyLibs(type: Copy) {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
    from configurations.customConfig
    into "$project.rootDir/dependencies/"
}

Note the small addition regarding the duplicatesStrategy to avoid an error.

In Android Studio you can open the .gradle file, scroll to the .copyLibs task and click on the green arrow button on the left side.

This downloads the .aar files into a folder called dependencies. Among many others there is a file named chat-ui-4.3.2.aar.

Afterwards you can extract .jar files from .aar, just like described in this nice answer.

Manual Check

Finally if you want to do it manually or check against the .pom file: you can download the .pom file from here: https://s3.amazonaws.com/salesforcesos.com/android/maven/release/com/salesforce/service/chat-ui/4.3.2/chat-ui-4.3.2.pom

The other sub-dependencies are also listed there.

Upvotes: 2

Related Questions