I have made a program that is working fine. It 3 screens and the second screen contains 24 images (the letters of the greek alphabet). The third screen just has a canvas. Each of the image is not bigger than 10kb. Also the size of the .aia file is only 274 kb.
When i run it in emulator or in the tablet with only 10 letters (not using images for the others) as i told is working fine. When i compile it (size 1724 kb) the program starts normally. But after trying to go to the second screen it crashes.
I upload the apk and the aia in case you have any idea to help me...
Thank you very much!
The apk file was removed by the moderators as a security issue. Apk files are not permitted on the forum. Thank you for the aia Stamatis ..someone will probably use it to provide advice.
--
This thing looks familiar to me from an earlier thread.
I think that something funny is going on because I got a runtime error like this:
Failed to allocate a 1697272 byte allocation with 158932 free bytes and 155KB until OOM
Note: You will not see another error reported for 5 seconds.
Note: You will not see another error reported for 5 seconds.
However, I totally fail to understand what you are tring to achieve in your app. Maybe you should start with less functionality and continue only when you have that working to satisfaction.
--
I'm looking into your problem. Try "Responsive" mode for the "Sizing" property on Screen1. Let me know if things work better, as in they don't crash, when you use Responsive mode. Thanks.
--
Smart people (like Jeff) are still looking at your problem, it may involve a memory leak. Stay tuned.
In the meantime, it could help to make your images smaller again, because they seem to be still way
--
The issue most probably is not the image file size but the size in pixels. Most of your images are 572 x 779 pixel images and all are displayed at reduced size.
You are stuffing the 572x779 images in spaces that are 15% H and 22% width on screen 2 ...there are 24 like this... AI2 is getting a heart attack of processing of scaling.
The images are four across ,so this could work on a 572 x 4 = 2288 pixel wide x 6 x 779 = 4674 high tablet ... and that is for only 80% of the screen. Wow. Is there such a Tablet?
AI2 has a scaling issue with stuffing this many images into 24 images in one fell swoop. This is not new, we have been counselling users not to stuff large pixel x pixel files into small buttons, telling them to right size the original in the media...then their apps work. When you use a percentage of the screen's height and idth you are stuffing large pixel x pixel images into a smaller space. When Android developers use Android Studio or other professional compilers, the developers provide multiple copies of the images they use for different screen densities. In the AI2 compiler, to allow novice programmers a lot of flexibility, MIT chose to use scaling of images as a simpler solution. At the moment, their algorithm is not right and the only work around is probably to use same size images.
Are you a Java user? You might be able to fix this, however, AI2 users either use use exact size pixels x pixels or put up with memory or other issues. MIT is aware of the problem. This is no quick fix.
I expect, but do not know, that when you use the larger images, internally in the AI2 compiled code, your png or jpg images are converted to bmp format . These images are significantly larger than the png images. It appears once the bmps are created at full size internally, the image is not destroyed on use .. (this is speculation). So, a lot of memory is used which may exceed the memory available to your app
If you use exact size images, you probably will not get that error, but we do not know. Perhaps try rezizing the images you store in Media by 50%...that might let you proceed (or you might have to right size the images).
AI2 is a learning tool; not a commercial app creation tool; so any user has got to deal with the problems associated with MIT using creative solutions to simulate the performance of the professional compilers. MIT is looking at this issue and may or may not be able to provide a solution in the near or even far term.
Be aware MIT warns users Responsive is very experimental. They are still attempting to allow Fixed to perform as in Version 144 and earlier; it does in most apps but does not work as hoped in some apps such as yours. Because Google changed how Android works in about September, MIT can no longer provide the gimmick they used in earlier versions of AI2 (they simply magnified the screen to make it fit on Tablets) You now have Fixed and Responsive and everything is not perfect.
I would make my 'original' images smaller ... a real fix might be a long time coming . Perhaps MIT will get lucky and find what the code that is possibly memory leaking soon. To move ahead now, resize.
--
Thank you very much.
Finally it works.
When i reduced the size of the pixels by 75% everything was fine.
For another time thank you very much!!!!
--
I am happy it works now.
--
Here is my analysis of the situation with the tafa_light application.
Yes, we have a memory leak. It only effects the Companion. We will fix it.
However the App itself uses many images, all of which are ten plus times the size they should be. The “Alphabet” of greek letters are each about 1-3 Megabytes in size. There are about 20 of them.
On most Android devices, the maximum size of Dalvik (the virtual machine that runs apps) memory is about 50 Megabytes. When displaying Screen2, the Alphabet, it just about completely fills memory when they are not scaled. Because of the memory leak, when you left Screen2, the memory was not cleared. The additional use of Screen3 (or going back to Screen1) would cause an out-of-memory error. Most applications do not recover from such an error.
Since the “Responsive” release [1] we have been automatically scaling images to compensate for each device’s screen density. On my One Plus One, the density factor is 1.3. This means that each images is increased in size by a factor of 1.7. When you add this additional memory, the Dalvik “heap” overflows and the application crashes. This is independent and not related to the memory leak. It just requires too much memory.
The solution is to resize the images. Most images appear to be 500x750 pixels (which is about the size of a typical phone’s entire screen). I suggest that you use an image editing tool to rescale them to 50x75 pixels. Then you shouldn’t have any significant memory issues. From reading the last message in this thread, it appears you have already done this and it now works.
[1] Prior to the Responsive release we set applications minSdk value to 3 (it is now 4). When set to 3, Android itself did the scaling and we didn’t have to. However with minSdk of 3, we cannot size applications to fit on tablets. Tablets wind up looking like big phones! We are also seeing newer devices that do not implement this compatibility scaling, so App Inventor was not working correctly on these devices. Going to a minSdk 4 means we can support these devices and tablets, but we have to do the scaling in our code.
--
댓글 없음:
댓글 쓰기