How can I make android delete old native libraries? -


i'm trying delete native libraries application because don't use them anymore, after install apk in phone can see native libraries still there. i've seen, android copy/update native libraries correctly replacing file in libs/ directory, apparently doesn't delete them when they're not in apk anymore. how know libraries still there? first of application's size remains same , i'm deleting big libraries, , second, if leave system.load(...) statement app still able load library.

the solution i've found has been uninstall app , make fresh install, that's not obvious solution user updating app google play, , yes problem affects severely app functionality.

i've checked , apparently can delete files self, during service creation, don't want mess installation way.

do know if there's way tell android needs delete native libraries , copy them again?

thanks, mike

[edit]

i've found gb updates libraries correctly, deletes now-missing should, neither ics nor jb do, 2 leave old .so files when they're not in apk anymore.

i tried deleting .so files manually /data/data/mypackage/lib won't let me.

any ideas?

ok, gave on android , had myself. took tips here: http://www.moodstocks.com/2012/03/20/ice-cream-sandwich-why-native-code-support-sucks/.

here's did:

  1. make 3 zip files contents of folders libs/armeabi, libs/armeabi-v7a , libs/x86 , named them libs_armeabi.zip, libs_armeabi_v7a.zip , libs_x86.zip respecively.

  2. move zip files res/raw folder.

  3. delete files under 3 libs folders , re-create them touch (in -nix system), remember ics , jb don't delete old files in lib folder, deleting files cause app keep files quite large.

  4. verify processor architecture programmatically these 2 methods:

    public static boolean isarmv7() {     try {         return build.version.sdk_int >= 4 && build.class.getfield("cpu_abi").get(null).tostring().startswith("armeabi-v7");     } catch (throwable e) {}      return false; }  public static boolean isx86() {     try {         return build.version.sdk_int >= 4 && build.class.getfield("cpu_abi").get(null).tostring().startswith("x86");     } catch (throwable e) {}      return false; } 
  5. depending on processor architecture unzip 1 of 3 files programmatically folder want, i'm using /data/data/mypackage/app_libs (using context.getdir("libs",context.mode_private); returns path).

probably there more logic involved here, extracting libs_armeabi.zip file, , extract files either libs_armeabi_v7a.zip or libs_x86.zip or none of them, overwriting files have same name (i'm wandering here because haven't tried that), fortunately me libs on 3 files renamed , exclusive on each zip file, need extract 1 of 3 files.

  1. replace system.loadlibrary method calls system.load supports loading libraries using full path, , add full path each library.

this method comes added benefits:

  • as libraries zipped apk size reduced, making application in google play store smaller.

  • being libraries stored inside raw resources android won't copy them automatically, allowing copy them wherever want , load them using full path.

  • you can decide copy libraries sd card if want, wouldn't recommend you're able it, example when phone doesn't have enough space.

hope helps!


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -