最近调试一款新的机型时,出现"此应用专为旧版Android打造,因此可能无法正常运行。请尝试检查更新或与开发者联系"提示,出现这种错误的原因:
应用启动,startActivity时,流程会执行到realStartActivityLocked方法,代码位于ActivityStackSupervisor.java
realStartActivityLocked方法中,会调用AppWarnings.java的onStartActivity方法,如下:
final boolean realStartActivityLocked(ActivityRecord r, ProcessRecord app, boolean andResume, boolean checkConfig) throws RemoteException {
try {
// ...
mService.getAppWarningsLocked().onStartActivity(r);
// ...
} catch (RemoteException e) {
// ...
}
}
onStartActivity方法实现:
/**
* Called when an activity is being started.
*
* @param r record for the activity being started
*/
public void onStartActivity(ActivityRecord r) {
showUnsupportedCompileSdkDialogIfNeeded(r);
showUnsupportedDisplaySizeDialogIfNeeded(r);
showDeprecatedTarge