App designer (Matlab 2020b) does not 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!

4 Comments

Post the code related to this DesignTimeproperties.
I didn't write any code in my app related to 'DesignTimeproperties'. Also I made a backup of my app file yesterday, but it can't be opened by app designer today as well. All other apps can be opened.
I attached my *.mlapp file.
You'll have to contact the customer service to fix this.
i have the problem when i want to open my .mlapp file it's says Error loading 'my.mlapp'. i don't know why. I am using MATLAB_R2022a

Sign in to comment.

 Accepted 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.

8 Comments

I wonder how you editted an mlapp file that cannot be opened by app designer?
it's actually a zip file masquerading as a .mlapp
I have exactly the same problem here. How do you edit the code without app designer? I tried to unzip it and edit the 'document.xml' but that won't work. I assume 'document.xml' is only for record.
@Zeyu Shi: You cannot fix this issue by editing anything stored in the .mlapp file using a text editor.
As @Andrew Dahlberg pointed out, the .mlapp file is just a zipped file, but within the zipped file there are both text and binary files, and the issue at play here is part of one of the binary files (not the text files).
If you need help fixing an app that has been corrupted due to this issue, my recommendation is to contact MathWorks Technical Support. But, if you want to try to do it on your own, the technique I used when fixing the app earlier was to put a breakpoint in the code that loads the .mlapp file. While stopped at the breakpoint you need to delete the extra axes that was created from the loaded figure, find all the UIAxes in your figure and reset the CreateFcn back to empty, then clear the breakpoint and resume the load process. The exact details will vary from one app to another, and the exact location of the breakpoint needed will be different for different versions of MATLAB.
Disclaimer: Once again, I recommend working with MathWorks Technical Support instead of trying this on your own, but if you want to try it on your own, here are the commands I used. Please be careful, and backup your app before you try this yourself.
% Set breakpoint
dbstop in appdesigner.internal.serialization.util.ComponentObjectToStructConverter at 32
% Load app
open app2.mlapp
% When the breakpoint first stops, the component should be a figure:
component
% Check that the figure has an axes as the last child.
component.Children % The last child will be an axes. This is causing the problem.
% Delete the axes.
delete(component.Children(end))
% Find all the remaining UIAxes.
ax = findobj(component, 'Type', 'axes');
% For each axes, set the 'CreateFcn' to empty.
set(ax,'CreateFcn', '');
% Clear breakpoint and continue.
dbclear all
dbcont
This worked for MATLAB R2020b with the app attached above. The exact details will vary from one app to another, and the exact location of the breakpoint needed will be different for different versions of MATLAB.
@Zeyu Shi, @Benjamin Kraus is correct -- inside that zip file there are several binary files that can be loaded in as Matlab variables. I ended up going in and reconfiguring several in a trial-by-error fashion to delete the offending axes handle. It worked and it beat Mathworks technical support in fixing the app by a week and a half or so if memory serves -- again highly recommend backing it up as I corrupted it more than once during the process.
@Andrew Dahlberg I'm sorry it took technical support so long. If you do contact MathWorks technical support, make sure to reference this post, and hopefully that should expidite the process.
@Benjamin KrausThank you so much! The problem is resolved by this technique you offered. I've spent so much time on editing matlab variables that @Andrew Dahlberg mentioned (a lot thanks too). I think my problem was that I put disableDefaultInteractivity(app.UIAxes) in my startupFn. I don't have problem closing and reopening the app now but I also cannot reproduce the issue.
@Zeyu Shi: I'm happy to hear that your problem is resolved.
As far as I know, this problem only arrises when you call disableDefaultInteractivity(gca), using gca instead of passing in your UIAxes handle.
It should be safe to put disableDefaultInteractivity(app.UIAxes) into your startupFcn. If this caused trouble for you, and you can reproduce the issue, please report the problem to MathWorks Technical Support (reference this conversation).

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!