0

I'd like to access(read) my .so file built in NDK at runtime in order to check up on its hash value.

To do that, I used AAssetManager_open() function but always failed.

const char* filename = "/data/data/com.mycompany.app/lib/libmyndk.so"; // failed with this.

const char* filename = "assets/libmyndk.so"; // Also failed with this.

AAsset* asset = AAssetManager_open(mgr, (const char*) filename, AASSET_MODE_UNKNOWN);

Please let me know why it persist to fail.

vaultah
  • 44,105
  • 12
  • 114
  • 143
GT Kim
  • 329
  • 1
  • 4
  • 16

5 Answers5

1

I solved out this issue. We don't need to use AssetManager for just simply accessing.

just use fopen() in NDK(c/c++ files).

for example,

void initNDK()
{
     const char* filename = "/data/data/com.company.app/lib/libmyndk.so";
     FILE* fp = fopen(filename, "rb");
     if(fp) 
         TRACE("Success");
     else
         TRACE("Failure");
}

Thank you All.

GT Kim
  • 329
  • 1
  • 4
  • 16
0

you have load .so file during application start.

By

static {
    System.loadLibrary("libpacman");
}

Than you can access file .

i hope this is help you.

Bhagirathsinh Gohil
  • 673
  • 1
  • 9
  • 25
  • Pretty good idea. but What can I do with this? Could you give an example to read the so file in binary mode or anything else? – GT Kim Nov 10 '14 at 06:01
0

Have you tried:

const char* filename = "libmyndk.so";
sybond
  • 167
  • 9
0

Above all, I succeeded in reading/accessing some file in assets folder with AAssetManager_open(). But this AAssetManager_xxxx() functions seem to be only available to access files in assets folder.

What I want to do is to access my .so file built in NDK. Still looking for answer.

GT Kim
  • 329
  • 1
  • 4
  • 16
-1

If you want to use native files you need to use android NDK.

This link will help you if you use Eclipce: How do I import a native library (.so file) into Eclipse?

And this is for Android Studio: http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-studio/

I hope it helps to resolve your problem.

Community
  • 1
  • 1
QArea
  • 4,955
  • 1
  • 12
  • 22