在Android Studio中创建一个module或者导入一个module的时候,如果这个module中依赖了aar库,当build工程的时候,会出现failed to resolve这个错误
这时候,只要在app的build.gradle中加入下面代码就可以完美解决了:
- repositories {
- flatDir {
- dirs project(':taesdk').file('libs')
- }
- }
上面代码中的“taesdk“替换成module的名字,libs是module依赖的aar库所在的目录。如下:
- apply plugin: 'com.android.application'
-
- android {
- compileSdkVersion 25
- buildToolsVersion "25.0.0"
- defaultConfig {
- applicationId "com.paxsz.ossdemo"
- minSdkVersion 19
- targetSdkVersion 25
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- repositories {
- flatDir {
- dirs project(':taesdk').file('libs')
- }
- }
- dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:25.0.1'
- testCompile 'junit:junit:4.12'
- compile project(':taesdk')
- }
这时候再去编译,就不会出错了