谷歌播放控制台警告应用程序正在使用不受支持的API



我已经在谷歌播放商店上传了我的应用程序,应用程序报告了2条警告

以下API为灰色列表,谷歌无法保证它们能在现有版本的Android上运行。有些可能已经被限制用于您的目标SDK

API Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows((V4已识别的事件。仅显示唯一堆栈跟踪

堆栈跟踪1(statck跟踪中的APP类:在com.elaxer.Registration.onCreate(Registration.java:6((

StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V
at android.os.StrictMode.lambda$static$1(StrictMode.java:428)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Class.java)
at java.lang.Class.getPublicMethodRecursive(Class.java:2075)
at java.lang.Class.getMethod(Class.java:2063)
at java.lang.Class.getMethod(Class.java:1690)
at androidx.appcompat.widget.TooltipCompatHandler.cancelPendingShow(TooltipCompatHandler.java:19)
at androidx.appcompat.app.AppCompatDelegateImpl.shouldAnimateActionModeView(AppCompatDelegateImpl.java:268)
at androidx.appcompat.app.AppCompatDelegateImpl.calculateNightMode(AppCompatDelegateImpl.java:4)
at androidx.appcompat.app.AppCompatDelegateImpl.getMenuInflater(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.initializePanelMenu(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onKeyUp(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onSaveInstanceState(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.updateResourcesConfigurationForNightMode(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:4)
at com.elaxer.Registration2.onCreate(Registration2.java:6)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:184)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

堆栈跟踪2(statck跟踪中的APP类:在com.elaxer.Splash_one.onCreate(Splash_one.java:45(

StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V
at android.os.StrictMode.lambda$static$1(StrictMode.java:428)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Class.java)
at java.lang.Class.getPublicMethodRecursive(Class.java:2075)
at java.lang.Class.getMethod(Class.java:2063)
at java.lang.Class.getMethod(Class.java:1690)
at androidx.appcompat.widget.TooltipCompatHandler.cancelPendingShow(TooltipCompatHandler.java:19)
at androidx.appcompat.app.AppCompatDelegateImpl.shouldAnimateActionModeView(AppCompatDelegateImpl.java:268)
at androidx.appcompat.app.AppCompatDelegateImpl.calculateNightMode(AppCompatDelegateImpl.java:4)
at androidx.appcompat.app.AppCompatDelegateImpl.getMenuInflater(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.initializePanelMenu(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onKeyUp(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onSaveInstanceState(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.updateResourcesConfigurationForNightMode(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:4)
at com.elaxer.Splash_one.onCreate(Splash_one.java:45)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:184)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

APILandroid/view/view;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect(Z已识别2个事件。仅显示唯一的堆栈跟踪。

堆栈跟踪1(statck跟踪中的APP类:在com.elaxer.Splash_one.onCreate(Splash_one.java:45(

StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z
at android.os.StrictMode.lambda$static$1(StrictMode.java:428)
at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
at java.lang.Class.getDeclaredMethodInternal(Class.java)
at java.lang.Class.getMethod(Class.java:2064)
at java.lang.Class.getDeclaredMethod(Class.java:2047)
at androidx.appcompat.widget.TooltipCompatHandler.<clinit>(TooltipCompatHandler.java:23)
at androidx.appcompat.widget.TooltipCompatHandler.cancelPendingShow(TooltipCompatHandler.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.shouldAnimateActionModeView(AppCompatDelegateImpl.java:268)
at androidx.appcompat.app.AppCompatDelegateImpl.calculateNightMode(AppCompatDelegateImpl.java:4)
at androidx.appcompat.app.AppCompatDelegateImpl.getMenuInflater(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.initializePanelMenu(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onKeyUp(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.onSaveInstanceState(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatDelegateImpl.updateResourcesConfigurationForNightMode(AppCompatDelegateImpl.java:0)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:4)
at com.elaxer.Splash_one.onCreate(Splash_one.java:45)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate(MonitoringInstrumentation.java:184)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

我正在gradle 中使用以下库

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
testImplementation 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.preference:preference:1.1.0'
implementation "androidx.paging:paging-runtime:2.1.1"
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation "androidx.room:room-runtime:2.2.3"
annotationProcessor "androidx.room:room-compiler:2.2.3"
implementation 'com.google.android.exoplayer:exoplayer:2.9.0'
implementation 'androidx.emoji:emoji:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.iceteck.silicompressorr:silicompressor:2.2.2'
implementation 'com.github.hani-momanii:SuperNova-Emoji:1.0'
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5'

implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-core:17.2.1'

implementation 'com.facebook.android:facebook-login:[4,5)'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true
}
implementation 'androidx.exifinterface:exifinterface:1.1.0'

我找不到修复此警告的方法。请帮我摆脱这些警告。

您的应用程序正在使用makeOptionalFitsSystemWindows方法(直接或通过嵌入式库(,这是一种非SDK方法/隐藏方法。

有很多方法可以检测非SDK接口测试应用程序的问题用法。最简单的是veridex工具或使用StrictMode API。

如何使用严格模式:创建严格模式对象并使用detectNonSdkApiUsagepenaltyListener

public void onCreate() {
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(new ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()   // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new VmPolicy.Builder()
.detectNonSdkApiUsage()
.penaltyListener( Executors.newSingleThreadExecutor() , new StrictMode.OnVmViolationListener(){...} )
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
}
super.onCreate();
}

注意:请确保使用Android 9(API 28级(来测试和验证问题。

从Android 9(API 28级(开始,平台限制非SDK接口您的应用程序可以使用

最新更新