Canvas: trying to draw too large

2021-12-22

The app file is 18.0MB

1 Like

It took more than 1 minute for the system to load the AIA into AI2, which means the file is quite large. What server are you using? code.appinventor.mit.edu or ai2.appinventor.mit.edu?

1 Like

File name: Elena_y_Tonito.apk

File size: 23.3 MB

That's strange.

1 Like

The only screen the Canvas appeared was TABLERO, and from your APK, it completely works. However, I noticed that you have a lot of assets - more than 100 files.

Are you sure the app you published to Google Play is the exact same app you posted?

If they still don't work, please read these links and topics.

2 Likes

The file size is 18.1 MB for me, but 161346240 bytes is around 154 MB, which means something is not right.
To be honest, I know little about this topic, but I googled the error description and found these:


(not very relevant link from what I can see, but it is top 3 result)

(5 years 4 months ago, but it's Stack Overflow I guess?)

(Android studio)

If I had to guess, I think your problem is that you are trying to draw a file that is either way too large or way too detailed for the screen size. I would suggest making any images you're using much smaller.

1 Like

Try instead of publishing an APK to Google Play, use an AAB.

You're not the first person to encounter this problem before, some of us also had this issue.

1 Like

@Gordon_Lu is more qualified; I wasn't even able to open the file. My last parting words of wisdom are "make sure you don't have any very large images"

2 Likes

Try to remove some big files that you do not need.

Asset limit for APK: < 10 MB, better < 5 MB

Asset limit for AAB: < 20 MB, better < 5 MB

1 Like

I saw the same blogs.

They say that is a problem in android, android try to resize the image and that close the app.

somebody recomend to use this code
android:hardwareAccelerated="false"
How can i put this code on app inventor?

1 Like

In some mobiles the app close the first time and the second is running normaly, I use the abb on play console, google doesnt work with apk anymore

2 Likes

The problem is not the files, the problem is the first app run

1 Like

You can't I believe; those people are working with Android Studio, which is a different platform altogether (a very similar one though).

1 Like

As Gordon said, try using (packaging and publishing as) an AAB instead of an APK and see if that works.

3 Likes

i already use the aab file.

1 Like

Well then I'm not sure what to do; I'd wait and see if someone else responds

2 Likes

I guess the main reason is still the assets, so it affects the first time loading but the second time is OK. Installing an app on Google Play does have some differences than directly downloading the app through the build QR code.

Meanwhile, I noticed that some of your images were text that could be easily replaced with the Label component, and sound files that could be replaced.with TextToSpeech. Please use built-in components to replace them.

Also don't forget that you can use a URL as a source for Images, Players and Sounds. You can upload a sound or image file in Google Drive, share it so that anyone on the web can view, and copy the share link. In you blocks (not in the Designer), set the Image/Player/Sound 's Picture/Source to the URL.

3 Likes

It is probably the image loaded to the canvas imageSprite OBJ_TABLERO on your TABLERO screen

image

Try loading it on screen initialise with a clock timer, to give the canvas some time (@250ms) to set its size before loading the image

4 Likes

If your app has a 1750 by 2500 image, is it intended for a phone the size of a handball court?

3 Likes

Note that just because an image is compressed doesn't imply that it is small. A 1750x2500 pixel image could be fairly small if using PNG compression on an image that is mostly solid colors without a lot of noise. However, in memory it still needs to be held in its uncompressed state, which is roughly 17.5 MB. If you end up loading a few images of this size you will cause the app to run out of memory (Fun fact: my first Android phone allowed apps to use up to 16 MB of RAM).

4 Likes

I think it is solve. Let me explain. when the sprites are loading they go outside of the screen, so my canvas change its size. Let me explain you.

Before the srpites load outside of the canva so I think is the reason of the error.

1 Like