SDK Detection on Android and IOS

I am currently developing a POC SDK, I need to add the ability to detect if any other third-party SDK (from the final list) is present in the current application that uses my SDK.

For example, detecting that the Google Maps SDK is being used.

What will be the approaches to this in Android and iOS?

+6
source share
3 answers

Android

  • . : , . : , . , , , , , .
  • apk . : . : classes.dex .
  • (, gradle). : . : (, gradle).
+4

IOS

IOS, F43nd1r. , .

Google Analytics. Google Analytics GAI ( API). GAI , , SDK Google Analytics.

if NSClassFromString("GAI") != nil {
    print("App is using Google Analytics SDK")
}

Android

Google Analytics.

try {
    if (Class.forName("com.google.android.gms.analytics.GoogleAnalytics") != null) {
        Log.d(TAG, "App is using Google Analytics SDK");
    }
} catch (Exception ex) {

}
+2

, ?

: -,

:, , , , , , .

Android

(SDK).

  • ( .jar libs gradle)
  • (.so), . System.loadLibrary(String) Runtime.getRuntime().load(String)

, :

 URL[] urls = ((URLClassLoader) classloader).getURLs();
 List<String> jars = new ArrayList<>();
 for (URL url : urls) {
     jars.add(url.getFile());
 }

: Thread.currentThread().getContextClassLoader()

, classloader null.

To load the downloaded .so libraries, you can scan the file / proc / your -pid / maps. See this existing answer for a code snippet. How to determine which native shared libraries are loaded by an Android application

As you compare yourself to your list, the intersection of the two is the answer you are looking at.

ArrayList<String> sdkHitlist = myStaticHitList;  //assume populated somewhere
ArrayList<String> currentLibraryList = new ArrayList<String>();

//fill the current list with .jar and .so file strings as above
sdkHitList.retainAll(currentLibraryList);  
+1
source

All Articles