Unsupported API warnings in Google Play Store

I had similar issues I got the NonSdkApiUsedViolation Logs by adding the below code in onCreate() of my MainActivity, it gave me the precise location of the API call causing it.

if (BuildConfig.BUILD_TYPE.contentEquals("debug")) {
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy
        .Builder()
        .detectAll()             // Checks for all violations
        .penaltyLog()            // Output violations via logging
        .build()
    );

    StrictMode.setVmPolicy(new StrictMode.VmPolicy
        .Builder()
        .detectNonSdkApiUsage()  // Detect private API usage
        .penaltyLog()            // Output violations via logging
        .build()
    );
}

When running your application, should the execution of any code trigger a StrictMode violation, you should see a stack trace in the logging output indicating what triggered it:

D/StrictMode: StrictMode policy violation; ~duration=28 ms: android.os.strictmode.DiskReadViolation
  at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1596)
  ...

After manually testing your application, searching your log output for StrictMode should help you find these easily.

Google's documentation on StrictMode also provides some additional guidance:

If you find violations that you feel are problematic, there are a variety of tools to help solve them: threads, Handler, AsyncTask, IntentService, etc. But don't feel compelled to fix everything that StrictMode finds. In particular, many cases of disk access are often necessary during the normal activity lifecycle. Use StrictMode to find things you did by accident. Network requests on the UI thread are almost always a problem, though.


These warnings refer to the usage of restricted non-SDK interfaces. https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces

These calls may lead to incorrect behavior or app crashes. It is recommended to avoid them. All usages belong to blacklist, greylist, or whitelist. If you can't get rid of these usages, check affiliation to list. Only blacklisted calls lead to crashes. Also, just to remind, Android Q (targetSDK=29) has updated blacklist https://developer.android.com/preview/non-sdk-q