Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce Android Studio Project Size

People also ask

Can I delete build folder Android studio?

Yes, you can delete the Build folder. If you are running Windows and you are not able to delete the folder, make sure you are the owner of the folder. Go to folder properties/security and check if your name is listed as the owner.

Why does app size increase after installation?

Since apps are compressed when they're downloaded, it can make install sizes larger than download sizes. When an app has a larger install size, more space is required on a user's device to complete the installation.


Yes, you can safely delete the intermediates folder. You can even delete the whole build folder that contains intermediates. The build folder and it's contents will be re-generated the next time you run/build your project though.


In Android Studio, go to the Terminal window. If you did not go to a different directory since you opened the IDE, you should find yourself on the top level of your project folder (something like ../Android Studio/projectname). There you simply type

./gradlew clean

That's it. I just reduced my project folder size from 589 MB to 21 MB.


The file .gitignore containted in the project created by AndroidStudio lists all files / patterns not to be stored in the git repository, i.e. those files that are not required for building the project. Therefore, it should be safe to remove all files / directories matching the patterns listed in the .gitignore file.

In my projects it lists:

*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

Please find the batch file I use to do that. Set the batch under the root of your project directories. Hoping it helps.

@rem  ##########################################################################
@rem
@rem  Export an ANDROID STUDIO application 
@rem
@rem  ##########################################################################


echo off
CLS
echo _________________________________________
echo ANDROID-STUDIO files sources export
echo _________________________________________
echo 
echo If directory name includes space
echo - Surround name with quotes 
echo _________________________________________
set /p dirname= Dir name to export :
if %dirname% == "" goto ERROR
set str=%dirname%
mkdir c:\EXPORT\%str%
pause
xcopy %dirname% c:\EXPORT\%str% /s
del c:\EXPORT\%str%\*.iml
del c:\EXPORT\%str%\app\*.apk
rmdir c:\EXPORT\%str%\.gradle /s /q 
rmdir c:\EXPORT\%str%\.idea /s /q 
rmdir c:\EXPORT\%str%\build /s /q 
erase c:\EXPORT\%str%\app\build /f /s /q
rmdir c:\EXPORT\%str%\app\build /s /q 
pause
goto END
:ERROR
echo Cannot create, check the directory root
goto OUT
:END
CLS
echo _________________________________________
echo  ANDROID-STUDIO EXPORT
echo _________________________________________
echo Export ended, check c:\EXPORT
:OUT
pause