2017년 3월 7일 화요일

My project,Soccer Kick,say that the it cant be compiled, what can I do?


When you get compilation errors, it's usually because something's wrong with your blocks.  AppInventor has a built-in system to show you where you have a problem, and what you need to do to remedy the problem.

If you look at the bottom of the workspace, you'll see a button and two icons above it.  This is the warning area.  In the first shot, everything's OK and the warning signals in the screen blocks are hidden (when the button says "Show Warnings," they're hidden) and at this stage, there are no warnings.

In the next screen shot, I've separated the number block from the global variable block for Date.
Notice how the count next to the warning triangle above the button now indicates that there are 2 warnings.  But where IS the problem???  
Well, now it's time to SHOW the warnings, so click on the button that says "Show Warnings."  It's caption will change to "Hide Warnings," but warning triangles now appear in the blocks as shown int he shot below.
Now, when you click on one of those warning triangles in the upper left hand corner of your blocks, App Inventor will tell you what you need to do to rectify the problem!  The reason there are TWO warnings is that each block has a warning about being disconnected. See below:
And that's it... Let AI tell you what you have to address when you have a compilation error!  See how it looks below, with the error fixed.  Once the two orphaned blocks are joined again, your warning counter will clear those two errors.  Now, you can click on the button that now says "Hide Warnings. and you'll be back to where the screen shots started above!
--
The RED colored warnings is a certain indication that there are coding errors and your app apk will not compile.  Usually, if you have the YELLOW colored warnings, you will have no issue compiling your app.   However, you should also try to eliminate as many YELLOW errors as possible; it is just good coding practice..

Another thing that prevents compiling is if your code is over 5MB in size; this includes resources (images, sound clips etc.). because they are compiled into the app apk.   If you make an aia file (your source code file) and the file is larger than 5MB, the code will not compile.   

Is your app larger than 5 Mb?  Do you see the RED warnings?      Did you fix the problem?  W like to know if you found a solution, knowing helps us help others.

--
Thank you for your response:  So I think that my project is largest than 5MB,can I do something to get it compiled?

Yes.  You can do several things.

1) Decrease the size of your Media resources attached to your app.  You probably added most of them from the Design screen (near the bottom).  Click on one of the resources   a png file for example.    You can Delete it from the menu there.   You may have some resources that you are not using.  These can be safely deleted, however, if you delete something referred to in your blocks, you have to replace it with something with the identical name whose file is smaller.  Usually png files are small, jpg, slightly larger and avoid bmp files all together.    Your goal is that the apps extra files should be as small as possible because they are included in the app size.

If you are using images, you probably loaded some at high resolution images,, make these images lower resolution using a Windows program like Paint.and reload them.

If you have sound files, consider shorter files.

Another major impediment is the number of blocks you use in your app.  You can reduce the number by coding smarter; reusing code etc.
1) Use procedures for repeating events.  Any code that you use over and over again can probably be put in a procedure.  Less blocks but you have to code smarter.
2) Develop different algorithms.  Virtually anything you code probably can be coded in an alternative way.  So, when something is working, consider refactoring.  Make the app do something but using less blocks.
3) Avoid multiple screens.
4) Avoid lots of layout components and a minimal number of components.  fewer components, faster refreshes and smaller app size.
5) Do not use the Do It feature  ...at least make sure you turn off individual question marks before you terminate your coding session.  Frequently if you leave Do Its open, when you start again, you may have screen stability issues and I suspect the app size is slightly larger than without
6) Do not comment in the blocks...this is probably a small block savings but all savings add up.
7) Do not leave unconnected blocks on your screen.   I am not sure this affects app size, but it might and it adds to your total block count which good programmers want to keep to a minimum.

Those are some ideas, there might be other suggestions somewhere on the forum.  

Also, be aware there are techniques to load resources outside of your app.  Perhaps someone will explain that here.

--
To overcome the App Inventor project limit of 5 MB 

--

댓글 없음:

댓글 쓰기