在module的gradle中加入 flatDir { dirs'libs' };详细如下
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.exuifoxtest"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
/**
ndk{abiFilters 'armeabi-v7a'}**/
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
repositories {//添加仓库位置
flatDir {
dirs'libs'
}
}
}
另外module中依赖
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//noinspection GradleCompatible
implementation 'com.android.support:support-v4:26.1.0'
implementation project(':tencent_appgame_bird')
//implementation(name: 'mylibrary-debug', ext: 'aar')(1)//必须要在仓库添加后(不然会报错),再添加单个依赖包文件
implementation files('libs/mylibrary-debug.aar')(2)//和(1)一样,都是在添加仓库后添加单个依赖包文件
}
上面的红色两个,两种方式都可以对aar或jar资源进行添加到module中(1)和(2)选择一个就可以,亲测有效。
//implementation(name: 'mylibrary-debug', ext: 'jar')
implementation files('libs/mylibrary-debug.jar')
还有一中方法,添加libs目录下所有依赖包,上面是单个添加,这里是一次性全部添加
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])