Error: Insufficient memory (Failed to allocate 2040518915616 bytes) in OutOfMemoryError

Can you please tell me the steps to generate opencv android sdk from source code. I am able to build sdk from 4.9.0 and 4.10.0 source code using build_sdk.py. but but not with older version like 4.2.0 - 4.7.0. It is aksing to turn OF android project build. Please help to solve the issue. I am new to this.