Google Play商店中不受支持的API警告

时间:2019-05-11 07:33:56

标签: android unity3d

我在Google Play的发布前报告中收到以下警告。

我不知道如何纠正这些问题。任何帮助或建议表示赞赏 我在这里有很多问题

Android compatibility
 We’ve detected that your app is using unsupported APIs. Tests may not have found all unsupported APIs. Learn more
 
 Unsupported
  12 warnings identified
 The following APIs are greylisted and Google can’t guarantee that they will work on existing versions of Android. Some may be already be restricted for your target SDK
 
 
 API Ljava/lang/invoke/MethodHandles$Lookup;-><init>(Ljava/lang/Class;I)V
 11 occurrences identified. Only unique stack traces are shown.
  
 API Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/Handler;Landroid/os/UserHandle;)Z
 1 occurrence identified
  
 API Landroid/media/AudioSystem;->getPrimaryOutputFrameCount()I
 1 occurrence identified
  
 API Landroid/media/AudioSystem;->getPrimaryOutputSamplingRate()I
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V
 1 occurrence identified
  
 API Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V
 1 occurrence identified

4 个答案:

答案 0 :(得分:2)

我遇到了类似的问题,通过在MainActivity的onCreate()中添加以下代码,得到了NonSdkApiUsedViolation日志,它为我提供了引起该错误的API调用的精确位置。

if( BuildConfig.BUILD_TYPE.contentEquals( "debug" ) ){
        StrictMode.setThreadPolicy( new StrictMode.ThreadPolicy.Builder()
                                            .detectAll()
                                            .penaltyLog()
                                            .build());
        StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder()
                                       .detectNonSdkApiUsage()
                                       .penaltyLog()
                                       .build());
 }

答案 1 :(得分:1)

如果您使用Xamarin,我相信Kailash的回答是:

#if DEBUG
    StrictMode.SetThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .DetectAll()
            .PenaltyLog()
            .Build());

    StrictMode.SetVmPolicy(
       new StrictMode.VmPolicy.Builder()
            .DetectNonSdkApiUsage()
            .PenaltyLog()
            .Build());
#endif // DEBUG

答案 2 :(得分:0)

这些警告涉及受限制的非SDK接口的使用。 https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces

这些调用可能导致错误的行为或应用程序崩溃。建议避免使用它们。所有用法都属于黑名单,灰名单或白名单。如果您无法摆脱这些用法,请检查从属关系以列出。仅列入黑名单的电话会导致崩溃。另外,提醒一下,Android Q(targetSDK = 29)已更新了黑名单 https://developer.android.com/preview/non-sdk-q

答案 3 :(得分:0)

我也有同样的问题,但是有不同的警告。请检查here, 如何解决警告