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

标签 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

最佳答案

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

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()
    );
}
在运行您的应用程序时,任何代码的执行是否会触发 StrictMode违规,您应该在日志输出中看到堆栈跟踪,指示触发它的原因:
D/StrictMode: StrictMode policy violation; ~duration=28 ms: android.os.strictmode.DiskReadViolation
  at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1596)
  ...
手动测试您的应用程序后,在日志输出中搜索 StrictMode应该可以帮助您轻松找到这些。
Google's documentation on StrictMode还提供了一些额外的指导:

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.

关于android - Google Play 商店中不支持的 API 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56751556/

相关文章:

Android ==> 子 Activity ?

android - 在android中的另一个 View 上方放置/重叠(z-index) View

android - 是否可以配置 GCC 为 android 进行编译?

c# - UnityWebRequest如何打印所有Request headers

java - 应用因违反我们的恶意行为或用户数据政策而被 Google Play 拒绝

Android - facebook sdk 问题

c# - 为什么编译器选择了错误的方法重载?

c# - UWP App 停止接收 UDP 多播消息

c# - 如果我扩展一个 c# 接口(interface),我可以吃一个电话吗?

c# - 团结跟随领导行为