开发者

Android @+id in layout xml crashing app

开发者 https://www.devze.com 2023-01-12 17:56 出处:网络
Firstly, I am new to android development. My app has been working fine with a number of different activities up until today.

Firstly, I am new to android development. My app has been working fine with a number of different activities up until today.

I have been trying to add a new <Button /> element to one of my layout xml files. However, if I give it a new id (e.g., android:id="@+id/button_unique") my app crashes on load, presumably as the resources are being loaded. If I change the id to an existing id (or remove android:id attribute completely) then the app loads fine.

The new resource id does appear in R.java. However, I can see a No package identifier when getting value for resource number 0x7f060000 error in the logcat console. I'm not sure if this 开发者_StackOverflow社区is related?

Perhaps i'm making a silly mistake somewhere, but if anybody could help me get to the bottom of this it would be much appreciated.

Thanks


I fixed this issue by rebuilding from scratch as the other post said. I entered ant clean before I built.


It is really tough to know without you posting a code example, but one possible solution that could work is after naming the new unique button, is resave and rebuild the project before running it again in the emulator. That will resave the new change in R.java which does not happen without the force of resave/rebuild. Hope that helps. Good Luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消