Android .aar 依赖项未在依赖于 .aar 的应用程序项目中解析
Android .aar dependencies aren’t resolving in app project that depends on .aar
我在 android studio 2.1.3 中创建了一个 android 库 AAR,我在其中使用了以下依赖项:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
现在我在应用程序中使用这个 aar,但是那些依赖项失败了,除非我将它们添加到新应用程序的依赖项中。
我在这里搜索,发现我需要添加以下行:
compile (project(':LIBNAME-release')) {transitive = true}
但这没有用。我错过了什么吗?或者它与我对 aar 文件所做的混淆有关?还是必须将这些依赖项添加到应用程序?
请按照以下步骤使其正常工作(我已经在 Android Studio 2.2 之前对其进行了测试)
假设您将 aar 文件保存在 libs 文件夹中。 (假设文件名为 cards.aar )
然后在应用程序 build.gradle 中指定以下内容并单击同步项目与 Gradle 个文件。
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile(name:'cards', ext:'aar')
}
如果一切顺利,您会看到在构建 -> exploded-aar 中创建了库条目
另请注意,如果您从另一个具有依赖项的项目导入 .aar 文件,您也需要将这些文件包含在 build.gradle 中。
先尝试编译你的项目:
dependencies {
compile project(':Name-Of-Your-Project')
}
这是 Ashton Engberg 来自 that post
的建议
我在 android studio 2.1.3 中创建了一个 android 库 AAR,我在其中使用了以下依赖项:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
现在我在应用程序中使用这个 aar,但是那些依赖项失败了,除非我将它们添加到新应用程序的依赖项中。
我在这里搜索,发现我需要添加以下行:
compile (project(':LIBNAME-release')) {transitive = true}
但这没有用。我错过了什么吗?或者它与我对 aar 文件所做的混淆有关?还是必须将这些依赖项添加到应用程序?
请按照以下步骤使其正常工作(我已经在 Android Studio 2.2 之前对其进行了测试)
假设您将 aar 文件保存在 libs 文件夹中。 (假设文件名为 cards.aar )
然后在应用程序 build.gradle 中指定以下内容并单击同步项目与 Gradle 个文件。
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile(name:'cards', ext:'aar')
}
如果一切顺利,您会看到在构建 -> exploded-aar 中创建了库条目
另请注意,如果您从另一个具有依赖项的项目导入 .aar 文件,您也需要将这些文件包含在 build.gradle 中。
先尝试编译你的项目:
dependencies {
compile project(':Name-Of-Your-Project')
}
这是 Ashton Engberg 来自 that post
的建议