Fix build errors and api level