MATLAB: App designer (Matlab 2020b) does not open *.mlapp file

app designercan't open mlapp file

I have created an app in matlab 2020b app designer and currently it is not possible to open it in app designer. The error message is: " Unrecognized method, property, or field 'DesignTimeproperties' for class 'matlab.graphics.axis.Axes' " . But if double click on the *.mlapp file, it opens and works fine. How the problem might be fixed?
Thank you!

Best Answer

I've attached a fixed version of your app (app2fixed.mlapp).
The problem with the app was that one of the UIAxes stored in the app had the CreateFcn set to disableDefaultInteractivity(gca). This is a bad idea, and I'll get to that in a moment.
As the app is saving, the call to gca is creating a regular axes (not UIAxes), which was being added to your app and saved along with your app. Then, when you loaded the app, the additional regular axes was confusing the loading process.
I deleted the extra axes, and removed the CreateFcn from the UIAxes, and resaved the app for you.
The root of the problem (I suspect) is that you have set the DefaultAxesCreateFcn in MATLAB set to be 'disableDefaultInteractivity(gca)' which is not recommended and is going to cause lots of other problems.
The issue is the call to gca, which will only work if the axes has HandleVisibility set to 'on' and if the parent figure of the axes also has HandleVisibility set to 'on'. Otherwise, gca will create a new axes instead of operating on the axes you think it should. In App Designer, the figure has HandleVisibility set to 'off' by default.
The better way to achieve the same goal is to use a function handle and set the DefaultAxesCreateFcn like this:
set(groot, 'defaultAxesCreateFcn', @(ax,~) disableDefaultInteractivity(ax))
The difference here is that the axes handle itself is passed directly to disableDefaultInteractivity so it is no longer dependent upon gca working.