Android Studio 項目中整合百度地圖SDK報Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create:()I錯誤

來源:互聯網
上載者:User

標籤:

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錯誤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.