27

Can anybody help why I am getting an error in the following?

Error:(7, 41) No resource found that matches the given name (at 'dialogCornerRadius' with value '?android:attr/dialogCornerRadius').

apply plugin: 'com.android.application'

//Add these lines
def Base_URL = '"' + WEBServiceBaseURL + '"' ?: '"Define BASE URL"';
def SMS_Base_URL = '"' + WEBServiceBaseSMSURL + '"' ?: '"Define SMS BASE URL"';

android.buildTypes.each { type ->
    type.buildConfigField 'String', 'Base_URL', WEBServiceBaseURL
    type.buildConfigField 'String', 'SMS_Base_URL', WEBServiceBaseSMSURL
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.bla.bla"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

apply plugin: 'com.google.gms.google-services'
Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55
Pavan Pyati
  • 950
  • 2
  • 13
  • 18

9 Answers9

54

I fixed this issue by selecting

API 27+: Android API 27, P preview (Preview)

in the project structure settings. Following image shows my setting. The 13 errors that were coming while building the app, have disappeared.

My Gradle settings

Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55
Jon
  • 3,174
  • 11
  • 39
  • 57
  • 1
    @Jon, Its not giving any error. Thanks for the answer but I'm unable to run in my Device, as its giving minSdk(API 27, P preview)! = deviceSdk(API 24) Any idea what can be done? – Pavan Pyati Mar 08 '18 at 12:33
  • 1
    @PavanPyati what do you have in your build.gradle file for these values? compileSdkVersion 'android-P' buildToolsVersion '26.0.2' – Jon Mar 09 '18 at 07:56
  • @Jon yes, same like what you mentioned. – Pavan Pyati Mar 09 '18 at 13:32
  • Build is successful but i could not able to install this apk in device. am facing the issue while installing the apk is: There was a problem parsing the package. – Rajesh Mar 11 '18 at 09:55
  • Same here - can't install on device - Failure [INSTALL_FAILED_OLDER_SDK:... Requires development platform P but this is a release platform] – bukowski Mar 12 '18 at 09:20
  • May I know how to solve this error in ionic3 project, please? – Yuyang He Apr 09 '18 at 07:20
  • Looks like you can set `compileSdkVersion 'android-P'` in your build.gradle file as well, but how you would figure that out without using the IDE I don't know. – A. L. Flanagan May 11 '18 at 19:42
  • I was struggling with `style attribute 'android:attr/dialogCornerRadius' not found.` and many more isues regarding resource not found. I solved by updating compile sdk version to 29 (in my case variables.gradle had `compileSdkVersion = 29`) as shown in screenshot. Thanks for your answer. – Shivaji Mutkule Apr 18 '21 at 09:06
16

set your compileSdkVersion 28 let android studio download platform files

SHINERAJ ARATHIL
  • 466
  • 5
  • 13
5

if in your app level gradle if you have used compileSdkVersion = 27 then it will not work. You have to use version 28.

compileSdkVersion 28 buildToolsVersion '28.0.3'

Anant Shah
  • 3,744
  • 1
  • 35
  • 48
3

Change the line compile 'com.android.support:design:+' to compile 'com.android.support:design:26.+'

The gradle dependencies when the project is built is pulling down the latest versions since the + was telling it "get the latest version." the 26.+ will tell the build process to only update the latest version of v26.

Or to be even more specific and safe, change the line to a specific version, avoiding the + altogether. i.e. compile 'com.android.support:design:27.1.0'

Mike Ohlsen
  • 1,900
  • 12
  • 21
3

Change the following depedencies in your gradle:


compile 'com.android.support:design:+'

to:

compile 'com.android.support:design:26.1.0'

'com.android.support:appcompat-v7:26.+'

to:

'com.android.support:appcompat-v7:26.1.0'

Please note that you can specify any version, but make sure they both have the same version.

This will make sure that values-28.xml file is not created.

Lee Mac
  • 15,615
  • 6
  • 32
  • 80
0

After Everybody's help, I could resolve this issue & run app in lower version.

My updated build.gradle is like below.

Special thanks to all Genius out there!

apply plugin: 'com.android.application'
android.buildTypes.each { type ->
    type.buildConfigField 'String', 'Base_URL', WEBServiceBaseURL
    type.buildConfigField 'String', 'SMS_Base_URL', WEBServiceBaseSMSURL
}

android {
    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.dummy.dummy"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled  true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

}

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:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

apply plugin: 'com.google.gms.google-services'
Pavan Pyati
  • 950
  • 2
  • 13
  • 18
  • 1
    i have done the change. i used compileSdkVersion as android-P and buildToolVersion as 26 . i get build successful but not installing in device. – Rajesh Mar 11 '18 at 12:08
  • if i use compileSdkVersion as 27 then its not working. – Rajesh Mar 11 '18 at 12:14
0

forget about dynamic dependencies and replace them with fixed specific versions :

WRONG :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:+'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:+'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}

CORRECT :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:26.1.0'
    compile files('libs/jxl-2.6.jar')
    compile 'com.google.gms:google-services:3.1.1'

    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
}
AmiNadimi
  • 5,129
  • 3
  • 39
  • 55
0

Got the same error after unsuccessful migration to AndroidX. I reverted all changes which Android Studio made, cleaned project, invalidated cache/restart, and many other things but with no luck. Finally I found that Android Studio added two lines to gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

After remove those lines everything back to normal.

antygravity
  • 1,307
  • 10
  • 12
0

I tried all but it did not work. Finally, it worked after I changed target to 28 in platforms/android/project.properties.

change

target=android-26

to

target=android-28

Thanks

Krishna Karki
  • 749
  • 12
  • 31