Yes, you want to use Environment Variables. That is what they are for.
When you build in Dev, make sure the setting for Automatically create Environment Variables is turned on. Now, there is another action to perform which I will explain and then continue.
When you normally add something to a solution, and you have your own Publisher, let's pretend it has a prefix of hagru_ , any new items will have that prefix. however, when you use the setting to auto-create Environment Variables for Connections you create IN a Power App (via the Data Tab), it will NOT be this, it will be _new as if its part of the default solution(because it is), and not automatically added to your Solution.
So after you add all your data (which btw, if you did NOT have this setting on initially you will have to turn on the setting. Save. Publish. CTRL F5. Come back in, remove the data, save. CTRL F5 and re-add them (its to be safe the best process), it will create these Environment variables, you will need to go to your Solution, go to Add Existing, more.. Environment Variables and then select all the ones that got created to make them part of your solution.
Ok, now that they are there.
There are 2 settings for them.
1) that represents what the value is IN this environment
2) the default value
When you Import a Solution that has environment variables that act as Connections, it will prompt you to Select Existing Connections that point to your data in that environment, or create new ones, which will automatically point to the new environment data when you sign in and create the connection during import.
now the environment variables Value will be set to a Connection to data in that environment
That is what you want. What you are doing you definitely do not want to do as its not good ALM practices.
If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.
Thank you!
Sincerely, Michael Gernaey