but the a app when opened giving error " this API key is not authorised to use in this app package.
Question:
Please guide me how to use the API Key with my app. where to enter the app package and how to get the package name of my app in mit app inventor.
Did you copy the key exactly, without any additional spaces? To understand why you got an error, it is necessary to review how you used the code snippet. Do not reveal your api code (strike it out).
When you registered for your api, I believe they ask for a Project name (sorry don't remember); if your new Project has a different identification, that might be the issue. Unfortunately I don't know.
The original advice was provided in 2020 (two years ago). Google may have changed their terms of service. I expect you need to provide separate 'billing' instructions for each Project. I do not think your issue involves SHA-1 at all, merely that the project is not properly set up for billing. The map api is 'free' only for a certain amount of usage (all your projects). Users get a 12-month or $300 credit free trial. When this free trial ends, I think you presently will get up to 28 000 map requests per month and 40 000 direction calls per month, free of charge. You will only be billed when your usage exceeds your monthly $200 credit limit. Google needs a way to provide accounting and uses a Billing Account. Is yours set up?
It's important to note here that the companion package is different than your compiled app. If you're restricting based on package you will need to allow for both if possible. Otherwise, you'll always need to compile to test your app since naturally all app package names need to be unique.