1. 在工程-app目录下,新建libs目录;
2.在libs目录下,新建armeabi目录;
3.将so包拷贝到此目录下;列如
lib_file_so.so
4.在app的gradle文件中加入:
sourceSets { main { jniLibs.srcDirs = ['libs'] }} // so包打包***
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.bangoli.testwebview"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jniLibs.srcDirs = ['libs'] }} // so包打包***
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
5.使用so包的位置:
System.load("lib_file_so.so");
或者:
System.loadLibrary("file_so");
static {
try {
System.out.println("libpropertyplus init start.2..");
String file_so = "";
//if ( System.getProperty("sun.arch.data.model").equals("64") ){
//file_so = "propertyplus-64";
//}else{
file_so = "propertyplus-32";
//}
//System.load(file_so);
System.loadLibrary(file_so);
//so.delete();
System.out.println("libpropertyplus init ok");
} catch (Exception e) {
System.out.println("libpropertyplus init Error;" + e.getMessage());
System.out.println(e.getMessage());
}
}