I build an aar file. It use some dependency. build.gradle file of my libray:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
My aar file path -> app/libs/mylibrary.aar
I edit top level build.gradle file
allprojects {
repositories {
...
flatDir {
dirs 'libs'
}
}
}
Add the library as a dependency
implementation(name:"mylibrary", ext:"aar") {
transitive = true
}
My application id: my.sample.app
./gradlew app:assembleRelease
Task :app:processReleaseManifest /SampleApp/app/src/main/AndroidManifest.xml:6:5-21:19 Warning: application@android:label was tagged at AndroidManifest.xml:6 to replace other declarations but no other declaration present /SampleApp/app/src/main/AndroidManifest.xml:6:5-21:19 Warning: application@android:icon was tagged at AndroidManifest.xml:6 to replace other declarations but no other declaration present /user/.gradle/caches/transforms-2/files-2.1/eb66b88fff0dbb2e75f036f5373b5bbf/res/layout/activity_btb.xml:10: AAPT: error: attribute 'my.sample.app:layout_constraintLeft_toLeftOf' not found.
I add dependencies that used by library, the error is gone.
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation(name:"mylibrary", ext:"aar") {
transitive = true
}
But this is not best way. How can I fix this error? Why my library couldn't find its dependecies.