Android存储库在库模块中不工作
我有一个应用程序模块和库模块的项目。应用程序模块可以正确导入库模块。但奇怪的是,当我试图通过在库模块中声明repository来获取库模块中的依赖项时,发生了一件事。library模块中的repository闭包根本不起作用,这意味着我无法从library libs文件夹读取aar或从指定的URL获取依赖项。我做错什么了吗 项目结构:Android存储库在库模块中不工作,android,dependencies,repository,libs,Android,Dependencies,Repository,Libs,我有一个应用程序模块和库模块的项目。应用程序模块可以正确导入库模块。但奇怪的是,当我试图通过在库模块中声明repository来获取库模块中的依赖项时,发生了一件事。library模块中的repository闭包根本不起作用,这意味着我无法从library libs文件夹读取aar或从指定的URL获取依赖项。我做错什么了吗 项目结构: ->App ->libs ->src ->LibraryModule ->libs // aar placed here
->App
->libs
->src
->LibraryModule
->libs // aar placed here
->src
库模块中的build.gradle:
plugins {
id 'com.android.library'
id 'kotlin-android'
}
repositories {
maven { url "https://jitpack.io" } // can not find URL here
flatDir {
dirs 'libs'. // can not find libs folder in library module
}
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
Implementation(name: 'testing', ext: 'aar') // Not working because libs folder in library module can not be found.
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
您是否在
settings.gradle
文件中声明了库模块?该文件位于项目的根目录中,您需要在其中添加库。您也可以检查此问题请查看更新的问题。正确导入库模块,这是库模块本身的问题。