標籤:
Android Studio 項目中整合百度地圖SDK報以下錯誤:
1 java.lang.UnsatisfiedLinkError: Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create)I2 at com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create(Native Method)3 at com.baidu.platform.comjni.map.commonmemcache.a.a(Unknown Source)4 at com.baidu.platform.comapi.c.c.b(Unknown Source)5 at com.baidu.mapapi.a.c(Unknown Source)6 at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source)7 at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source)8 …………
這個問題是由於JNI找不到方法,一般我們是用Eclipse開發,放在libs/armeabi 目錄下即可,但是Android studio 的目錄不同,用AndroidStudio的話 .so 檔案要放在src/main/jniLibs/armeabi 下面。
或者做以下修改(推薦):
在build.gradle檔案中android下增加以下代碼:
1 sourceSets{2 main{3 jniLibs.srcDir([‘libs‘])4 }5 }
完整設定檔如下:
1 apply plugin: ‘com.android.library‘ 2 3 android { 4 compileSdkVersion 22 5 buildToolsVersion "22.0.1" 6 7 defaultConfig { 8 minSdkVersion 9 9 targetSdkVersion "android.os.Build.VERSION_CODES.LOLLIPOP_MR1"10 versionCode 10011 versionName "1.0"12 }13 14 buildTypes {15 release {16 minifyEnabled false17 proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘18 }19 }20 // 移除lint檢查的error21 lintOptions {22 abortOnError false23 }24 25 packagingOptions {26 exclude ‘META-INF/NOTICE.txt‘27 exclude ‘META-INF/LICENSE.txt‘28 }29 sourceSets {30 main {31 jniLibs.srcDirs = [‘libs‘]32 }33 }34 }35 36 dependencies {37 compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])38 compile files(‘libs/android-support-v4.jar‘)39 compile files(‘libs/BaiduLBS_Android.jar‘)40 compile files(‘libs/zxing.jar‘)41 }
OK,搞定。
Android Studio 項目中整合百度地圖SDK報Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create:()I錯誤