Android Studio : Add library as reference, 不作为导入

标签 android android-studio android-library

这个问题是this one的续集。

在现有的 Eclipse 解决方案中,我有一个库项目,在主应用程序项目中用作 Android 依赖项。这意味着如果我编辑此库并进行编译,主项目将使用该库的最新版本进行更新。

我正在尝试在 Android Studio 中执行相同的操作。这意味着不导入库,而是将其用作应用程序项目中的引用或依赖项。我已经尝试了两天了,但没有运气。非常感谢您的帮助。

build.gradle(应用程序项目的 - 她没有什么有趣的,因为我没有对其进行太多更改)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

最佳答案

您可以尝试以下步骤:

  1. 下载库
  2. 文件/导入模块
  3. 选择您的图书馆并重命名:LibraryName
  4. 转到 build.gradle 并编写。

build.gradle

dependencies {
......
compile project(':LibraryName')
.....
}

然后,如果您导入模块,您可以编辑库并预测其更新

关于Android Studio : Add library as reference, 不作为导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28781006/

相关文章:

c# - 响应 BinaryWrite 不适用于 Android 浏览器

android - 如何更改 Gradle 中的 libs 目录?

android - 2018年安卓上的相册选图有什么方法?

android - 当我使用 ListView 时,ListTile OnTap 正在工作。但是当我使用 ListWheelScrollView 它不起作用

android - 在慢速连接上使用 picasso 加载图像

java - 首次开发Android应用程序时如何在Java中修复 "R.menu.main"?

android - 分发隐藏源代码的 Android 库

我的应用程序与 Java 7 不兼容的 Android Studio 错误

android - 如何告诉 android studio 预先存在的 NDK 的位置?

android - 不支持本地 .aar 文件