You for sure could and should (see reasons below) have swap memory. However, do not count on swap memory to solve shortages of RAM for your software.
Although you will be able to load and run android studio, you will quickly notice that in practice, it will not be workable. Swap is extremely slow, and you quickly will notice very slow response of your computer, so called "disk trashing" and occasional freezing for several minutes.
Swap would be faster if you would locate it on a much faster SSD drive. Even then, it would be significantly slower than using real RAM. The intensive writing would quickly wear out your SSD drive. Each area of an SSD drive supports a limited number of writes.
There are some reasons why swap memory nevertheless is useful. See here for one general reason. Other reasons to maintain swap are:
- To hibernate a computer. To be able to hibernate a system (turn fully off, but maintain the current session in SWAP so memory can be restored on next boot), a swap with a size of at least the memory of the system is needed. Caveat: it is quite common for hibernation not to work correctly with linux.
- To improve performance on low memory systems: On lower memory systems, some less used memory may be swapped to disk, freeing memory for other activities you are doing. Caveat: if memory becomes too limiting, you will revert to the unworkeable performance of the system I referred to above.
Bottom line is that you should not rely on the swap memory for daily use of software requiring a lot of memory. The only good solution here will be to invest in RAM.
Note that, if you did a fresh install of Ubuntu, you will not have a swap partition but a swap file. The installer should have that configured in an optimal way with respect to normal desktop usage considering the amount of RAM you have. I would leave the settings as is.