SoFunction
Updated on 2025-04-09

How to quickly import jar and .so files in Android Studio

Import jar

Put the jar file in the libs folder, right-click the jar, click the option add as library, click Confirm, and get it done.

Add so file

1. Add jniLibs folder in src/main and copy .so into it

2. Put the so file into the libs folder and add it in gradle

sourceSets{
    main {
       = ['libs']
    }
  }

Specific location:

apply plugin: ''
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
  compileSdkVersion 26
  defaultConfig {
    applicationId ""
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner ""
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile(''), ''
    }
  }
  sourceSets{
    main {
       = ['libs']
    }
  }
}
dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation ":kotlin-stdlib-jre7:$kotlin_version"
  implementation ':appcompat-v7:26.0.0-beta1'
  implementation ':constraint-layout:1.0.2'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation ':runner:1.0.1'
  androidTestImplementation ':espresso-core:3.0.1'
}

Summarize

The above is the relevant knowledge about how to quickly import jar and .so files in Android Studio that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!