There is no id when I run the app on the device

I have some automated scenarios in which I use driver.findElement(By.id(“sp_env”)). Those tests work fine on the emulator but when I run them on the device I get this exception
"
org.openqa.selenium.NoSuchElementException: An element could not be located
"
When I use UI Automator to inspect the app on the device, surprise!! the element does not have an id.
Do you have any idea about this problem.