yes,I have already did this .
private void loadLibraryFromAssets() { AssetManager am = getAssets(); String path = null; try { InputStream in; in = am.open("lib/libjni_xxx.so"); BufferedInputStream bis = new BufferedInputStream(in); path = Enviroment.getAppPath(this) + "libjni_xxx.so"; File file = new File(path); if (!file.exists()) { file.createNewFile(); } FileOutputStream out = new FileOutputStream(path); byte[] temp = new byte[2048]; while (bis.read(temp) > 0) { out.write(temp); } bis.close(); out.close(); //am.close(); can't be closed } catch (IOException e) { e.printStackTrace(); Log.e(TAG,"load Library From Assets error: " + e.getMessage()); } try { System.load(path); } catch (UnsatisfiedLinkError e) { String errorMsg = e.getMessage(); Log.e(TAG,"System.load error: " + errorMsg); } catch (SecurityException e) { String errorMsg = e.getMessage(); Log.e(TAG,"System.load error: " + errorMsg); } } On 8月4日, 下午3时03分, Kaj Bjurman <kaj.bjur...@gmail.com> wrote: > I'm not sure about this, since I haven't done it myself, but I've > heard that some people place the libraries under res/raw, and then > they copy it to /data/data/your-package-name when it's first started. > > On 4 Aug, 04:53, "xuxiake2...@gmail.com" <xuxiake2...@gmail.com> > wrote: > > > > > I have a .so library ,which I had put in directory "assets" . But > > how can i load it ? > > > I can't use System.loadLibrary or System.load because i can't get the > > path. thanks > > > in advance for your answers.- 隐藏被引用文字 - > > - 显示引用的文字 - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---