Error while generating apk

I have tried generating the apk multiple times but everytime it shows error while compiling

Why not show us the error ?

There you go

See here:

the link provided is not opening

True...
perhaps @SteveJG can provide a working link to the topic ?

Certainly the link is not working. The original was posted in about 2014 so this might be a Google issue.

Try this https://groups.google.com/g/mitappinventortest/c/fLiMEfPh09Q/m/1Ia0AaQEXogJ . I am not sure this is the same version. Why Taifun's link to the old forum post Monster List list disappeared, I have no idea.

Here is a reposting of the Monster List :slight_smile:
The tips and tricks are mostly in these resources, they help developers to use the AI2 tools A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles

How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Most frustration occurs when developers violate one of AI's basic rules which include:

  1. Always check for coding errors (the red and yellow triangles on the lower left of the Block screen). Red errors almost always will prevent the Project from compiling.

  2. Save aia files frequently (and with different names) and ensure the aia is smaller in size then 10 Mb.

  3. Do not use more than ten screens ever and use only one if you can using Horizontal and Vertical Layouts and setting the Visible property to true or false to show or hide them.

  4. Streaming video or music while developing make the blocks work slower; lots of open browser windows do the same.

  5. When you have lots of blocks and objects, disconnect from live development (WIFI/emulator/USB) and make changes to graphics having a little faith in the Designer, then go back to live development. App Inventor wants to refresh when text is changed in a label or button or you change a color and the device or emulator graphics refresh...sometimes this is like the doldrums. Disconnecting and coding 'blind' greatly ameliorates the 'bad' graphic refresh issues.

  6. You fill a horizontal layout with components and cannot scroll to see all of them so they can be edited. You cannot 'scroll' horizontally in the Designer. If you use Responsive Sizing, you can check the Check to see Preview on Tablet size. box above the Designer and see an 'expanded' view displayed. This might help. Do you need to see more? You can 'see' more of the objects you placed on the Designer by switching Screen1 Screen Sizing from Unspecified to Landscape.

Developers most frequently have the following issues that create issues when live developing or creating the apk (compiling)

  1. You have coding errors in your blocks. In the Blocks editor, look in the lower

left corner of the window for the yellow and red triangle icons. If the red icon has a value larger than 0,

you have a serious coding error. Find the block in your code that has a red triangle and

fix it. Red triangles always inhibit creating an apk or running a project in the

emulator or possibly creating an aia file. Yellow triangles are more forgiving,

however, sometimes, these need to be fixed because they trip an internal warning and not filling puzzle piece sockets that are left un-filled can sometimes cause issues if the app needs a value that is not filled.

  1. Your source file (the aia file) is larger than the 10Mb limit allowed in AI2 (the aia can not be larger than10Mb). You may have put images or other resources in your Media (resources) that you do not use in the app. All the images and sounds in resources count toward the 10Mb limit along with the source code. You can program apps larger than 10Mb in the browser, but the apps will not compile and might not run in the emulator or the project may not save as an aia. If this is the case you need to reduce the size of your image and/or sound files. Most image files can be made quite small by resizing them using a photo manipulation program on your PC to less than 50Kb each.

  2. You might have more than 10 Screens in your app. AI2 frequently becomes unstable when more than ten screens are used. Projects CAN be built with slightly more screens but then you should expect your app to occasionally behave erratically. Do not ignore the warning message that appears when you attempt to load your 11th Screen.

  3. You might have set a Screen icon in the Designer Properties for your project that is too large. If your image is too large, your app will not compile. Use an image size of 96x96 instead and only use jpg or png images. *.ico files are not supported. The 'icon' (actually an image) Google Play requires when posting needs to be 520x520 for their display. The smaller 'icons' work for the app's icon (the one shown on the device's screen that is pressed to activate the app). For nb181 there is now provision to accept larger images.

  4. You did not code the entire project using App Inventor 2. If you used one of the third-party AI2 clones,you might not be able to load a Project into the AI2 compiler or create an apk with the standard AI2. The various 'versions' of App Inventor have tools that are not available in AI2. Mixing and matching compiler code results in file corruption and failed compiles.

  5. If you incorrectly modified the project's Manifest files using a third-party tool, you may have issues returning to MIT App Inventor.

  6. Sometimes, if you have LOTS of Layouts on a single screen, the apk might not compile. How many is a lot? I do not know, keep adding layouts and buttons, compile and try again...when the server crashes, you got a lot.

  7. The network you use may be overloaded (possibly a school network), or you have other applications running in the background on your computer, or your virus checker is doing a scan. Sometimes, just trying to access the MIT server a few minutes later will give you a more favorable response.

  8. Do you have BlueStacks on your PC (BlueStacks is a special emulator that allows Android apps to run on a PC)? The Google emulator on AI2 cannot run unless BlueStacks is disabled and all of the BlueStacks processes are shut down. On a Windows PC, you use the Task Manager to 'kill' running processes.

  9. Are you using Sensor controls (except for the clock)? Most Sensor controls or controls related to sms or the phone do not work in the emulators. This includes the LocationSensor and Accellerometer. These components need to be tested on a device.

  10. If this is an issue about the Project loading slowly on your device or on the emulator: Be aware, the more images, layouts, components you have on a screen, the longer it takes for the emulator and Companion to render the graphical screen. How fast the emulator renders is partially a function of your hardware...how much ram you have, your cpu clock speed etc. Sometimes, with lots of graphics, the emulator will just give up. Can you develop live using WIFI or using USB? These options almost always render faster than the emulator but will not be at lightning speed if you have lots of graphics. Be patient.

  11. We have seen instances where it is probable the Google Cloud messed up; other instances where an older PC has had memory issues and caused file corruption of the Project and instances where a user is using a very slow Internet connection (like dial-up) and it is just too slow.

  12. Do you have an AVG, Eset or AVAST virus checker. Some versions of these products have been reported inhibiting/ running the emulator unless (in the case of AVG) the Advanced Link settings on the software are set to allow AI2 communication.

  13. Do you get the error: The blocks area did not load properly. Changes to the blocks for screen xxxxxxx_Screen1 will not be saved. One user had this error, the problem was he had too many comment boxes exposed at once for the browser to handle. Try minimizing all blocks, and opening in another browser,like Chrome or Firefox.

  14. Having issues getting AI to run at all, perhaps your firewall is blocking. Don't turn your firewall off, just allow AI2 to pass unhindered..some firewalls have the ability to allow or deny certain urls.

  15. If you get a build server busy ... It is possible the buildservers may just well be busy! If you get this message, just try the build again. MIT currently runs 3 buildservers all the time. They occasionally add a 4th or even a 5th. There is a load balancer which distributes work to the buildservers. If you get the "busy" message, either the load balancer could not find a buildserver with available resources or the the buildserver it assigned the request to decided it was too busy. The solution is to just try again, either immediately or in a few minutes. If this message persists, then something might be broken and you can report it on the forum. If something IS broken, MIT will find out about it soon enough!

  16. If you have excessive resources and suspect that might be causing problems, you can look at what is in the emulator. In both in the Companion via WiFi and in the emulator, with the emulator "up" you should be able to go to: http://127.0.0.1:8001/ on the PC running the emulator. Going to that url should show you a small (possibly empty) directly listing (it will be a list of the assets that are used in the emulator). If you do not actually use a file in your app, make sure you remove the files, images etc. that are not being actually used. These files bloat your program and count towards the 10MB limit, even if they are not used. If you do not use a tool, do not include it in assets..

  17. You might have used an alpha character in the app's Version number. The version number must be all numerical digits. Use of an alpha character will spawn a generic error message on attempting to compile.

If the connection times out, that is a problem! The aiStarter program uses the "adb" program (in the "commands-for-AppInventor" folder) to setup "tcp port forwarding" from the PC to the emulator on port 8001. This command could be failing for you. Make sure you don't have security software that is blocking the action of the "adb" command.

  1. The problem could be something else, like running an old version of Companion ...if this is the case the cure might be if you are using the emulator: Projects > Hard Reset. A pop up should appear (if no issues, nothing will happen...just smile). However, sometimes you need to close your browser and reload your project to update Companion with the emulator. When the pop up appears, follow the instructions very carefully, then reboot your PC and try again. Yes, Companion on your device must be the current Companion if you are developing live on a device.

  2. If this is a connection issue with WIFI: If the device is set up to be used with USB, the Android cannot be used with WIFI unless the Settings > [developers options] in the Android box next to USB debugging is unchecked in the device.

Some users try to use their phones BOTH with USB and WIFI. That can be done. To use the live development USB option the developer must have the USB debugging box checked. If developer later wants to use WIFI the USB debugging box should NOT be checked. If you switch from USB and then to WIFI, you may have to close and restart your browser to release cache items that tell App Inventor your are connected to USB or WIFI when that is not the case.

  1. Parse Error: The most common cause of a parse error is the device has run out of storage. Do you have lot of apps on your emulator? or Device? Try freeing up space there (clear the TinyDB perhaps-TinyDB.ClearAll), and see if that helps.

A second type of parse error may occur while attempting to update the emulator: When I got the "parse error" message in the emulator, I fixed it by..

  • uninstalling the tools via the Control Panel

  • rebooting

  • re-running the install file, but this time by right-clicking on it and running as an administrator

  1. Do you have lots of Windows open on your browser or are you streaming music or video?

  2. Large bmp or other image files ( 1 to 2 MB in size, 800 x 1500 pixels) loaded into a button that is 50 x70 pixels will cause Companion to fail when loading a project. The issue is AI2 must compress these images to the small size to make them fit in the small area. The solution is to make these files 50 x 70 pixels (or however large they must be in on the Android). Instead of bmp files, use jpg or png files. Consider png image files may not be as sharp as jpeg images but the png files scale better to different size screens.

  3. ai2 reports "Server error. Could not save one or more files."

Clear your browser's cache. Close the browser, then load it again. Try to build again. Sometimes switching from Chrome to Firefox or Safari or the reverse performs a miracle and corrects an issue related to the browser cache. Microsoft's Edge might seem to work for you, however our experience is it sometimes fails while the recommended browsers do not.

  1. for extension developers: The current best practice is to have a package per extension that contains all classes required for the extension so you may want to split up your classes accordingly.

  2. Several very different things seem to evoke the package installer has stopped message.1) Using a app icon 48 x 48 pixels (the png or jpg image you use to identify your app on a device set on the Designer screen). will evoke this issue. Use a196 x 196 jpg or png image. This is a very frequent issue that evokes the error.2) Removing unused files from Media (even though the aia is less than 5Mb) has cured the issue.3) If the apk installs on other phones, but not this one perhaps there isn't sufficient space on the phone. If the apk installs on other phones, it is not an issue with the apk. You may have too many apps on your device.

  3. Does the app work in Companion but not run the first time the apk is installed? If you use a TinyDB and set a default to empty instead of 0 on first run of the TinyDBy (initially the tinyDB contains no values)there might be a problem with the app until values are added to the TinyDB.

  4. Did you use an unusual character in your apps name, or a screen name like @ or # ? Using non alpha numeric characters in these names causes compile errors. Make sure your app name or any of the screens you created uses only alpha numeric characters.

  5. Are you developing an app to use on both tablets and phones using a large screen tablet? Ensure you check what the app will look like on the smaller device early in your screen design process or ...well, you will find out.

  6. Before finishing a project, build the apk several times and test on a actual device. Some programming bugs only manifest themselves in the compiled version. This is frequently the case when building apps with many screens, many layouts, many large image or sound files. Build an apk early, especially if you have a large Project and shield yourself from a huge problem. If your app is going to crash, find out early in your development process.

  7. Developing multiple Projects using the emulator and a TinyDB? Unless you occasionally use the call TinyDB.ClearAll block to free the TinyDB memory that is stored in the emulator will cause a crash. If you store a lot of data, you soon will cripple the memory allocated to the emulator and that may cause problems.

  8. When developing using the emulator and TinyDB and working with multiple Projects, try to avoid using the same tags in each Project or you might find yourself wondering why data from ProjectA suddenly appears in ProjectB. If you use a tag in ProjectA like messages and use the same tag in ProjectB, you will have issues unless your regularly clear the TinyDB memory while using the emulator.

  9. You try to compile put get a variety of error messages like " App Inventor is unable to compile this project. The compiler error output was" and/or "An internal error has occurred. Report a bug?" and the bug report includes this:

foundIn = nb167el3

faultData = java.lang.IndexOutOfBoundsException or something similar. . Did you previously compile your Project using Thunkable or another third part App Inventor clone and now you are attempting to compile of MIT App Inventor? MIT has seen Projects modified using Thunkable, and so some of the property settings on the screen fale to load because they are not valid in App Inventor . The message is simple, if you choose an App Inventor flavor to start your Project, stay with it. Mixing the coding is like making a cake using apples and oranges and sauerkraut. It probably is not going to work as expected. Once upon a time a developer might have been able to get away with using the various clones; not any more as each version of AI contains tools and objects that are not compatible or tools that do not exist in the other.

  1. You use a reserved word for the name of a Procedure or object, that probably will cause a compiling issue. These are reserved words:

enter image description here Make sure you always rename a Procedure when you make a new Procedure. Never use the default name 'Procedure'.

  1. Extensions. Extensions are usually created by third party developers. When AI2 or Companion is upgraded, frequently the extension too must also be upgraded. If the developer does not upgrade and his/her extension is not upgraded and you use it in your app, the Project might not build as the extension might not have the proper permissions. Extensions go 'stale'. Make sure you are using the developer's latest version of the extension.

:

Hope this helps. Others on the forum probably have other 'suggestions.".

Regards,

Steve

2 Likes

(FAQ link updated)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.