我们建立了一个我们分发给客户的图书馆.我们分发原始的aar文件供他们使用.我们还使用GitHub的原始访问API来提供Maven存储库.
现在为了保持整洁,我们将库分成几个模块:
include ':library'
include ':geohash'
include ':networkstate'
include ':okvolley'
include ':volley'
Run Code Online (Sandbox Code Playgroud)
library是一个Android库,所以是volley和okvolley和networkstate.
现在,当我发布时library,依赖树看起来像这样:
\--- com.sensorberg.sdk:sensorberg-sdk:0.10.0-SNAPSHOT
+--- com.squareup.okhttp:okhttp-urlconnection:2.2.0
| \--- com.squareup.okhttp:okhttp:2.2.0
| \--- com.squareup.okio:okio:1.2.0
+--- com.google.code.gson:gson:2.3.1
+--- android-sdk:okvolley:unspecified
| +--- com.squareup.okhttp:okhttp-urlconnection:2.2.0 (*)
| +--- com.google.code.gson:gson:2.3.1
| +--- android-near-gradle:volley:unspecified
| \--- com.squareup.okhttp:okhttp:2.2.0 (*)
+--- android-sdk:networkstate:unspecified
+--- com.squareup.okhttp:okhttp:2.2.0 (*)
+--- android-sdk:volley:unspecified
\--- com.loopj.android:android-async-http:1.4.5
Run Code Online (Sandbox Code Playgroud)
正如您所见,android-sdk:networkstate:unspecified并android-sdk:okvolley:unspecified显示在外部依赖项列表中.
我想library用捆绑的本地模块创建我的aar.它应该做一个本地清单合并和远jar ...并合并所有模块的依赖性.只显示外部模块.
我确实尝试从build/output/aar相应模块的文件夹中引用本地aar文件,但这似乎也行不通.它仍然似乎用他们的名字引用本地模块而不是合并jar的清单......
有人做过这样的事吗?在Android之外,这将被称为fatjar,并且有像musketyr/gradle-fatjar-plugin这样的插件,可以用Gradle生成一个胖子.
我在我的本地模块上试过这个
if (project.ext.libraryBuild …Run Code Online (Sandbox Code Playgroud) 我在我的DemoApp项目中使用android cuckoo.aar本地android库.
这个cuckoo库还通过Gradle依赖项使用了许多其他库,例如(retrofit,recyclerview,rx-android,rx-java).
当我在DemoApp中导入这个cuckoo库时,我需要在我的demoApp中添加库中使用的所有依赖项.
有一种解决方案是在gradle中使transitive = true.但它没有帮助我.
有人可以帮我正确地实现这一目标.
android android-library android-gradle-plugin android-gradle-2.0
我已经制作了一个自定义模块,并使用“ api”配置在其中包含了tensorflow-lite依赖项。我建立它的aar。现在,我创建一个新项目并将aar放在libs文件夹中。但是我只能访问我创建的类,而不能访问tensorflow api。如何在不再次包含传递依赖项的情况下使用传递依赖项?
我在博客(https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa)中将其替换为“ api” 。
build.gradle(模块:mylib)
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
aaptOptions{
noCompress "tflite"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api 'androidx.appcompat:appcompat:1.1.0-alpha04'
api 'org.tensorflow:tensorflow-lite:0.0.0-gpu-experimental'
}
Run Code Online (Sandbox Code Playgroud)
build.gradle(模块:新项目中的两个):
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner …Run Code Online (Sandbox Code Playgroud) android android-library android-gradle-plugin android-module
使用 Android Studio 3.XX,将本地 .AAR 文件添加到 Android 项目不起作用(构建成功但运行时出现异常)
我尝试下面的方法(摘自参考来源:/sf/answers/1632847821/,/sf/answers/1742607121/等),但没有为我工作:
1. Import the local aar file:
(I) File>New>New Module>Import the .AAR Package [On "Finish" click the .AAR gets included automatically into settings.gradle file as below:
include ':app', ':myAAR'
(II) Add AAR module dependency in app level build.grdle file as below:
implementation project(":myAAR")
2. Using flatDir method:
(I) keep aar file in libs folder
(II) Add flatDir{dirs 'libs'} into the project level build.gradle file as below:
allprojects { …Run Code Online (Sandbox Code Playgroud)