我在将 AndEngine 添加到 Google Android Studio IDE 时遇到问题。
- 我从 git 下载了 AndEngine 并将其解压到文件夹中。
- 在我现有的项目中,我单击了文件>项目结构>模型
- 在中间栏绿色加号>新模块>空模块,我选择了 AndEngine 文件夹
- 在中间栏中,我选择了我的项目,然后是 Dependencies>右侧的绿色加号>Module Dependency,然后我选择了 AndEngineModule。
当我尝试运行它时出现如下错误:
Gradle: error: package org.andengine.engine.camera does not exist
最佳答案
我也是这样!我不确定它是如何工作的。但似乎 Android Studio 使用“仅用于源代码”的库来查找库,然后 IDE 使用 Gradle 之类的外部构建工具。
所以我在我的项目中创建了 libs 目录并将 *.jar
文件移动到那里。我已将库文件 (*.jar
) 添加到项目依赖项中。我可以在我的项目源中使用 org.andegine
包,但我仍然有错误,所以我也将依赖项添加到 build.gradle
中。
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile files('libs/andengine.jar') // for single file
compile fileTree(dir: 'libs', include: '*.jar') // for all files in directory
}
关于Android Studio 和 AndEngine - 包不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17932621/