0

Is there any way to limit Android NDK Library to the Specific JAVA Application ? I would like to prevent programmers from using my lib in another applications.

EDIT

I'm building a shared library that will be used in another application by user(another programmer).

EDIT 2 this library also include a java library that interact with the native library via JNI.

Behrouz.M
  • 3,445
  • 6
  • 37
  • 64

1 Answers1

1

I would like to prevent programmers from using my lib in another applications.

... presumably for copy-protection of some sort.

You didn't say whether the "permitted" application is built by you or by someone else.

If the former, linking your library statically into the application will make it very hard to reuse that library elsewhere.

If the latter, you could use some techniques, such as looking in /proc/self/exe to find application name from within the library and exit if what you see there is not what you allow, but

  • such techniques will likely cause grief to your customers, and
  • will increase your support load (when they misfire under legitimate conditions), and
  • will be trivially bypassed by a moderately sophisticated adversary.

Which is to say that generally that's a waste of time.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Would you please provide code to the latter solution ``/proc/self/exe`` ? – Behrouz.M Sep 26 '15 at 19:30
  • 3
    @raypixar I just told you this is a waste of time, and now you want *me* to waste my time on a solution that doesn't generally work? Sure, I can do that. It will only cost you 1000USD. – Employed Russian Sep 26 '15 at 20:35
  • In my case, I will provide some activation code to the developers to use my library. What about encrypting the activation code with android application caller's ID ? In this case I just need to detect the application caller's ID and decrypt the activation code. – Behrouz.M Sep 27 '15 at 05:12
  • May be this link be useful for others: http://stackoverflow.com/questions/9982864/get-application-name-from-ndk – Behrouz.M Sep 28 '15 at 07:44