标签:
Android Studio 项目中集成百度地图SDK报以下错误:
1 java.lang.UnsatisfiedLinkError: Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create)I 2 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 100 11 versionName "1.0" 12 } 13 14 buildTypes { 15 release { 16 minifyEnabled false 17 proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘ 18 } 19 } 20 // 移除lint检查的error 21 lintOptions { 22 abortOnError false 23 } 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,搞定。
标签:
原文地址:http://www.cnblogs.com/leevey/p/4803325.html