0

below is my gradle file ANdroid studio is displaying this message

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:support-compat:27.0.2 and com.android.support:animated-vector-drawable:26.1.
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.t.t"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support:customtabs:26.1.0'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'

ANd when i am running the app, app crashes on run time displaying the following error java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)Landroid/graphics/Typeface; in class Landroid/support/v4/content/res/ResourcesCompat; or its super classes (declaration of 'android.support.v4.content.res.ResourcesCompat' appears in /data/app/com.example.tapesh.tapu_chat-2/base.apk)

Tapesh Gupta
  • 363
  • 7
  • 21

2 Answers2

0

I believe you are using build tool version 26.0.2 and you are using some support dependencies. Try this.

For example:

android {
    buildToolsVersion "26.0.2"

}

and

dependencies {

    implementation 'com.android.support:support-v4:26.0.2'
    implementation 'com.android.support:appcompat-v7:26.0.2'
    implementation 'com.android.support:recyclerview-v7:26.0.2'
    implementation 'com.android.support:support-v13:26.0.2'

}
lib4backer
  • 3,337
  • 3
  • 18
  • 16
  • I had made the change.. then also its not working – Tapesh Gupta Jan 20 '18 at 14:54
  • please paste your updated gradle after this change. – lib4backer Jan 20 '18 at 14:55
  • apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { applicationId "com.example.tapesh.tapu_chat" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } – Tapesh Gupta Jan 20 '18 at 15:07
  • dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.0.2' //implementation 'com.android.support:customtabs:26.+' implementation 'com.github.bumptech.glide:glide:4.5.0' implementation 'com.android.support:design:26.0.2' implementation 'com.google.firebase:firebase-database:11.8.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' } – Tapesh Gupta Jan 20 '18 at 15:07
  • did u tried adding 'com.android.support:support-v4:26.0.2' and 'com.android.support:support-v13:26.0.2' in ur gradle? – lib4backer Jan 20 '18 at 15:22
0

getFont() will work from Android 'O'(26.0.0-beta1) version

So update your build tool version to: "27.0.2"

Example: build.gradle

compileSdkVersion 27
buildToolsVersion "27.0.2"
targetSdkVersion 27

Updated Dependencies:

compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:customtabs:27.0.2'

Source

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62