android 新创建的项目r.layout.main有红叉,android学习笔记

这篇博客记录了作者在将旧版Android代码导入Eclipse时遇到的错误,包括项目错误提示、R.java文件丢失等。作者尝试了多种解决方案,如删除debug.keystore、检查构建路径、清理项目等。最终问题出在ADK工具上,通过重新安装ADK工具解决了问题。博客提供了详细的解决步骤,对于遇到类似问题的开发者具有参考价值。
摘要由CSDN通过智能技术生成

android学习笔记

1、以前的android代码,放到eclipse里:Your project contains error(s), please fix it before running it.而且只有项目名上有红叉,具体代码中并无错误,依照网上一些大众意见clean,结果R.java文件被删除,而且不再生成。

查找解决办法:

(1)

首先发现的解决办法是删除debug.keystore(我的在/home/xxxx/.android中),这个自动生成的密钥只能使用一年,删除后会重新生成。我删除,问题未解决。

(2)

再找:

That usually comes from errors in the build path.

If you’re using eclipse, there is a view you can add that lists all the errors called “Problems”.

Otherwise, you can try to clean the project, and that usually solves a few problems.

Finally, if you add or alter resources from outside your IDE, you’ll want to reload the resources and clean.

EDIT (Comment by anonymous user)

This can also be caused by an out of date “Debug Certificate” fixed as follows:

IF ALL FAILS THEN THIS GOTTA BE THE SOLUTION:

Delete your debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERPROFILE%/.androidon Windows.

The Eclipse plugin should then generate a new certificate when you next try to build a debug package. You may need to clean and then build to generate the certificate.

This is also another fix for the “setContentView(R.layout.main);” error that says it cannot find R.layout.main when it is actually generated. (R cannot be resolved to a variable).

This is also another fix for the error “Your project has errors…” and you cannot find any. Clean and rebuild are still necessary after generating a new debug certificate.

(from:http://stackoverflow.com/questions/4954316/your-project-contains-errors-please-fix-it-before-running-it)

(3)(2)中的老师提醒了我查看eclipse下的错误提示:error executing aapt. please check aapt is present at。。。。 查找后发现是adk tools的问题,我的adk tools已安装,重装,问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值