我正在尝试在 Android Studio(GameBaseUtils) 中添加一个目录作为依赖项。我已经看到其他 SO 答案只是为他们的特定问题发布了正确的 gradle 配置,但是我不明白如何根据我的情况调整他们的答案。
这是我所做的:
第一步:文件->导入模块->导航到目录并选择它。
第二步-:文件->项目结构->模块->选择我的应用程序->依赖项->将模块作为依赖项添加到我的项目中。
现在我的代码没有任何红线表示导入模块时出错。但是,当我选择构建时,出现以下错误:
Gradle: package com.google.example.games.basegameutils does not exist
Gradle: cannot find symbol class BaseGameActivity
Gradle: cannot find symbol variable super
...
这是我的应用程序的 build.gradle 文件
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
}
如何正确导入此外部库,您能否解释一下您的解决方案如何以及为何起作用?