Minsdkversion and Targetsdkversion are set up in the program as follows:
<android:minsdkversion= "8" android:targetsdkversion= "23" />
The version information for the device is as follows:
Error running the program, log as follows:
01-06 13:56:11.798:e/androidruntime (2396): FATAL exception:main01-06 13:56:11.798:e/androidruntime (2396): java.lang.nosuchmethoderror:android.view.display.getsize01-06 13:56:11.798:e/androidruntime (2396): at Com.xxx.xxx.activity.TutorialActivity.init (tutorialactivity.java:73) 01-06 13:56:11.798:e/androidruntime (2396): At Com.xxx.xxx.activity.TutorialActivity.onResume (tutorialactivity.java:64) 01-06 13:56:11.798:e/androidruntime ( 2396): At Android.app.Instrumentation.callActivityOnResume (instrumentation.java:1242) 01-06 13:56:11.798:e/ Androidruntime (2396): at Android.app.Activity.performResume (activity.java:4004) 01-06 13:56:11.798:e/ Androidruntime (2396): at Android.app.ActivityThread.performResumeActivity (activitythread.java:2515) 01-06 13:56:11.798:e/androidruntime (2396): at Android.app.ActivityThread.handleResumeActivity (activitythread.java:2546 ) 01-06 13:56:11.798:e/androidruntime (2396): at Android.app.ActivityThread.handleLaunchActivity (Activitythread.java:1859) 01-06 13:56:11.798:e/androidruntime (2396): at android.app.activitythread.access$1500 ( activitythread.java:135) 01-06 13:56:11.798:e/androidruntime (2396): at Android.app.activitythread$h.handlemessage ( activitythread.java:1041) 01-06 13:56:11.798:e/androidruntime (2396): at Android.os.Handler.dispatchMessage ( handler.java:99) 01-06 13:56:11.798:e/androidruntime (2396): at Android.os.Looper.loop (looper.java:150) 01-06 13:56:11.798:e/androidruntime (2396): at Android.app.ActivityThread.main (activitythread.java:4333) 01-06 13:56:11.798:e/androidruntime (2396): at Java.lang.reflect.Method.invokeNative (Native Method) 01-06 13:56:11.798:e/ Androidruntime (2396): at Java.lang.reflect.Method.invoke (method.java:507) 01-06 13:56:11.798:e/androidruntime (2396 ): At Com.android.internal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:849) 01-06 13:56:11.798:e/ Androidruntime (2396): at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:607) 01-06 13:56:11.798:e/androidruntime (2396): at Dalvik.system.NativeStart.main (Native Method)
Check the official documentation to learn:
The method is added in Android 3.2, the question comes up, what do you let 3.2 users do? When writing the code, the IDE has no hint that this method will not work.
For this version of Android compatibility issues really do not want to vomit groove, the final solution is to solve the problem is:
if (Build.VERSION.SDK_INT >= build.version_codes. HONEYCOMB_MR2) { // code block containing the new API else { // code block containing the old API }
The eggs were broken in one place.
How to understand Android version compatible???