If you are getting “internal error” messages and hitting quota limits, it may be that your files sizes became too large, 5000 lines for instance. Gemini is unable to refactor an entire app at that size. You have to help it break down the files. You may have to jump back and forth between Flash lite, 3.5 and Pro, to refactor the app in smaller pieces, and get back to app development.
The best method is to never allow your files to get over 3000 lines, but here’s what to do if you already exceeded that.
This process is effective and will build the app properly, but may result in small changes. Keep a good working copy of your app that you can reference to recall what it should do and look like. Gemini will function better with the smaller files sizes, and those edits can be made at that point.
Ask Gemini:
-
“What files in the code have more than 3000 lines?”
-
“Some of the files in this app have grown too large for Gemini to continue to develop without errors. Tell me what I need to do to help you easily extract and refactor those files separately into more manageable files under 3000 lines, and pass the necessary states forward so the app continues to compile perfectly, and future development is faster and more stable. I need instructions that I can give you that will enable you to clearly and accurately do this in small pieces to avoid provoking internal errors and quota limits from my current Gemini tier. Do not change anything yet. I just want a refactoring and extraction plan going forward that I can follow to ensure the app can be successfully restructured/refactored and development can continue without running into errors and quota problems.”
From that point it should give you two sets of instructions, similar to these below. One is to determine what the subcomponents of your file are; and the other is to instruct it to refactor those subcomponents one at a time.
- Please start refactoring [filename].tsx. First, analyze the file and tell me what the logical sub-components are. Specify the order to move the sub-components to enable the most meaningful and efficient changes first. Do not perform any edits yet.
Once you have those sub components you can pick whichever one you want or whichever one has been specified as the first one to use and then give Gemini the second prompt (just leave the “[NEW_FILE_NAME]” syntax below exactly as it is; Gemini will fill in that new file name by itself):
- Extract the [choose one subcomponent name/section provided in the answer from #1] into a new file at src/components/[NEW_FILE_NAME].tsx. Ensure all necessary state and props are passed through. Run lint_applet after the move to verify the fix.
Continue until you have reduced your large files to under 3000 lines maximum.