If you use the aws/codebuild/standard:2.0 CodeBuild managed image, you must specify a runtime version in the runtime-versions section of the buildspec file.
Like this:
phases:
install:
runtime-versions:
java: openjdk8
android: 28
ruby: "$MY_RUBY_VAR"