当我在 Android 上运行 Libgdx 项目时,代码的更改没有反映出来

2022-01-12 00:00:00 android eclipse libgdx

我一直在关注 Libgdx 教程 此处我遇到了一个奇怪的问题.由于工作环境的限制,无法在桌面上下载OpenGL驱动,所以无法在桌面上测试我的应用程序.我必须在我的 Android 设备上对其进行测试.它运行的是 Android 2.3.4 版本的一些变体,即 API 级别 10.

I've been following the Libgdx tutorial here and I'm running into a strange problem. Due to the constraints of my work environment, I can't download OpenGL drivers on my desktop, so I can't test my application on the desktop. I have to test it on my Android device. It's running some variation of an Android 2.3.4 build, which is API level 10.

问题是,每当我对代码进行更改并运行 Android 应用程序时,这些更改都不会反映.它只是在我第一次运行我的代码时启动它安装的构建.我在我的 Android 上卸载了该应用程序并重新运行它,遇到了同样的问题.我制作了一个全新的 Libgdx 项目并将我的新代码复制到其中,它运行良好,直到我对新版本进行了更多更改,然后我遇到了同样的问题.所以我知道一个事实,即我正在更改的代码正在改变它的外观,它只是没有被反映.我有什么遗漏吗?

The problem is, whenever I make changes to my code and run the Android application, the changes aren't reflected. It just starts the build it installed the first time I ran my code. I uninstalled the app on my Android and re-ran it, running into the same problem. I made an entirely fresh Libgdx project and copied my new code over to it, and it worked fine, until I made more changes to the new version, then I ran into the same problem. So I know for a fact that the code I'm changing is making a difference in how it should look, it just isn't being reflected. Is there something I'm missing?

我的步骤,澄清一下:

  1. 使用 gdx-setup-ui.jar 设置一个 Libgdx 项目
  2. 使用默认导入设置将新创建的项目导入 Eclipse
  3. 编写一段时间的代码,创建我的应用程序的某个版本(例如,在那个教程中,我编写代码直到设置调试 ShapeRenderer,并测试以确保我的应用程序看起来正确)
  4. 运行 Libgdx Android 应用程序以在我的手机上进行测试
  5. 编写更多代码、更改内容、添加内容等等(甚至更改我资产中的图像)
  6. 重新运行 Libgdx Android 应用程序以在我的手机上进行测试
    • 显示的应用程序与我在第 4 步中第一次运行时的应用程序相同
  1. Set up a Libgdx project with gdx-setup-ui.jar
  2. Import the newly created project to Eclipse using the default import settings
  3. Code for a while, creating some version of my application (for instance, in that tutorial, I code till I set up the debug ShapeRenderer, and test to make sure my app looks right)
  4. Run the Libgdx Android application to test it on my phone
  5. Code some more, changing things, adding things, whatever (even changing images in my assets)
  6. Re-run the Libgdx Android application to test it on my phone
    • The application that shows up is the same as it was when I ran it the first time in step 4

推荐答案

这是较新版本的 ADT 中的错误.请为错误报告加注星标让谷歌意识到这带来的麻烦.

This is a bug in the newer versions of ADT. Please star the bug report to make Google aware of the troubles this gives.

最简单的方法是在 Eclipse(或您使用的任何 IDE)中 clean project 或在您的 Android 项目中添加空格/换行符并保存.

Easiest way is to clean project in Eclipse (or whatever IDE you are using) or to add a space/newline in your Android project and save.

相关文章