android - Caused by: java.lang.UnsatisfiedLinkError: Cannot load library -


i writing game, , have huge native library, trying load native library in main activity like

 static {         try {             system.loadlibrary("mylib");         } catch (unsatisfiedlinkerror e) {             log.d(tag, "unsatisfied link error: " + e.tostring());         }     } 

i have tested code on many devices in house, don't error. published logs "caused by: java.lang.unsatisfiedlinkerror: cannot load library". note: crash not universal, few people getting crash

  • is problem library put in exported apk ? have library put /libs/armabi/libmylib.so automatically eclipse?
  • is thing version of android ? supporting android versions since 2.3 (api level 9)
  • or need load library different place?
  • or missing important
  • is problem whole app being installed on sdcard ?

more info on crash : load_segments: 68 failed map segment mylib.so

considering app works correctly on of devices , gives error, it's safe assume library packaged correctly in apk , size/memory footprint acceptable.

as such, i'll go on whim , suggest problem build/compile architecture of library. newer android devices use arm7 processor. it's quite library compiled against arm7 architecture well. older devices, running android 2.3, use arm6 processor (i have 1 such device use testing - lg gt540 running android 2.3.3), not forward-compatible arm7 architecture. have seen crash error similar 1 indicated (load_segments: 68 failed map segment mylib.so) when attempted run app designed arm7 on old arm6 phone.

there 3 ways of going around issue:

  1. compile library against both architectures , include 2 separate .so files apk. @ runtime determine type of processor , load correct one. frankly, don't know if possible.

  2. create 2 separate apk files - 1 arm6 , 1 arm7 - use filters in manifest specify corresponding architecture. can upload both of them google play same app - , filters in manifest control 1 downloaded device.

  3. only support arm7 architecture specifying device requirements in manifest. loose customer audience, have less work maintaining 2 versions of app.

edit: according ndk documentation, can produce multiple libraries different architectures in 1 go. can control cpus want target adding following line application.mk file:

app_abi := arch1 arch2 arch3 ... 

for example,

app_abi := armeabi armeabi-v7a mips 

then build process create different versions of native library. these versions need placed in final apk in directory

lib/<abi>/lib<name>.so 

where name of architecture. load library with

system.loadlibrary("<name>"); 

alternatively can build separate apk files each architecture use multi-apk functionality on google play.

you can find information on architecture targeting in file cpu-arch-abis.html file in docs subdirectory of ndk.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -