I am developing an app App
with a library (Android Module) Lib
. They had no problems when not interacting: after importing the library Android Studio messed up the build.gradle
settings and I am not able to recover.
I must target Android 4.4 - and nothing else. The appcompat library is installed and the dependency on it has been added to both the app and the library (I followed this guide: https://developer.android.com/tools/support-library/setup.html )
This is the build.gradle
of the module: app
(which corresponds to the application App
):
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "it.mydomain.myapp"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':mylib.mydomain.it')
}
This is the build.gradle
of the library:
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
Somehow Android Studio put the wrong API level in the gradle scripts when I started the project (or maybe it was me overlooking a step). After creating the project I had API level 21 both in the app and in the library. I modified the two gradle scripts to use API level 19, performed several clean/rebuild/build and other random attempts. I still get these errors when building the project:
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
and other 98 similar ones: all related to theme issues.
There are also other messages, referring to values v11
, v14
like:
/.../build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-v11/values.xml
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/.../build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-v14/values.xml
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(9, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/.../build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-v21/values.xml
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
'com.android.support:appcompat-v7:21.0.3'
requires API 21.
You have to compile your project with API 21. Use:
compileSdkVersion 21
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.