java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)

半世苍凉 提交于 2019-11-26 15:21:26

Fix res/values/styles.xml and Manifest.xml like so:This solution is tested and don't forget to clean and build :

1.Manifest.xml

change the theme of HomeActivity to :

        <activity
        android:name=".ui.home.HomeActivity"
        android:theme="@style/Base.Theme.AppCompat.Light" />
    <activity android:name=".BaseActivity"></activity>

2. res/values/styles.xml Make all your themes preceeded with Base :styles.xml will be like this :

<resources>

<!-- Base application theme. -->
<!--<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">


<!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="Base.Theme.AppCompat.Light">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="Base.ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="Base.ThemeOverlay.AppCompat.Light" />

Detailed explanation as requested: Theme.AppCompat.Light.DarkActionBar is a subclass of the superclass Base anyway. Ctrl+click (Android Studio) on it and you will be taken to the source:

<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />

3. GithubBrowser-Master.gradle

make support_version = "27.0.0" and not support_version = "26.0.2

4.app.gradle :

compileSdkVersion 27
    buildToolsVersion '27.0.0'

and not

   compileSdkVersion 26
buildToolsVersion '26.0.2'

this is work for me:

    buildToolsVersion "27.0.3"

and

dependencies {
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
compile 'com.android.support:support-v13:27.0.0'
}

In my case, I was using Android-KTX: implementation 'androidx.core:core-ktx:0.1' in Kotlin project, and that was the cause of the error. I just removed it from build.gradle as a dependency.

I also got this issue and resolve this issue by setting application gradle file.

Change your compile sdk version to 27 and buildToolsVersion to 27.0.3

compileSdkVersion 27

buildToolsVersion "27.0.3"

Add 27.1.1 version support libraries.

compile 'com.android.support:recyclerview-v7:27.1.1'

compile 'com.android.support:cardview-v7:27.1.1'

compile 'com.android.support:appcompat-v7:27.1.1'

and then sync project.

Thats it.

Make sure your comileSdkVersion and targetSdkVersion should be same :

and also update your dependencies to the latest version and sync the project and run it. it's helped me to resolve the issue.

I had same problem, fixed with just change the appcompat and design and recyclerview to these valeus:

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'

and sync gradle again

The compileSdkVersion 26 sometimes gives this error. To resolve it,please upgrade the compileSdkVersion and targetSdkVersion to 27 in app.gradle file. Also change the corresponding dependencies in dependencies section. You don't need to specify buildToolsVersion for this.

the version of all dependecies should be same with compileSdkVersion. so below code in build.gradle(module) work for me.

android {

     compileSdkVersion 26

 ...

dependencies {

implementation 'com.android.support:appcompat-v7:26.0.2'

implementation 'com.android.support:recyclerview-v7:26.0.2'

implementation 'com.android.support:cardview-v7:26.0.2'


...

In My case, This issue was coming because of the combination of Glide and Appcompat library (Versions are not supporting each other).

So below is what worked for me(In App level build.gradle)-

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'

Hope It will help somebody.

Just change activity theme in manifest to any one like:

android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"

The solution is really simple..u just need to change build tool to 27.0.2 And all supports library version to 27.0.2 Bingo..error solved

I tried to find an answer in this question but in my case it was my configuration:

android {
    compileSdkVersion 26
     defaultConfig {
        applicationId "com.jorgesys.gifanimated"
        minSdkVersion 14
        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'
        }
    }
}

To solve this issue i just add the definition of the buildToolsVersion and it works!

   buildToolsVersion "26.0.2"

Probably is necessary that our build tools version is the same as the support libraries version.

For me the problem was caused by one of my app dependencies using a higher version of Android Support Library than the one I was depending on. If you don't want to update to latest version just yet, you can force the use of your version of the library.

To see which dependency uses newer version, you can run: ./gradlew app:dependencies and look for com.android.support occurences that declare a different version than you are using. For example:

./gradlew app:dependencies \
  | grep com.android.support \
  | grep -vE "constraint-layout|support.test|multidex|->|26.1.0"

should show you dependencies that use a version different than 26.1.0. (Android Studio should also give you an example dependency conflict in a tooltip on some com.support.android dependencies listed in your build.gradle)

In my case it was com.android.support:support-compat:27.1.0 (and support-annotations), so run:

./gradlew app:dependencyInsight \
  --configuration <YOUR_BUILD_VARIANT>CompileClasspath
  --dependency support-compat

To see what library depends on 27.1.0 version of support-compat. (Replace <YOUR_BUILD_VARIANT> with one of your build variants, e.g. debug).

In my case it was:

com.android.support:support-compat:27.1.0 (conflict resolution)
\--- androidx.core:core-ktx:0.3
     \--- devDebugCompileClasspath

and replacing:

implementation 'androidx.core:core-ktx:0.3'

with:

implementation ('androidx.core:core-ktx:0.3') {
    exclude module: 'support-annotations'
    exclude module: 'support-compat'
}

fixed the issue for me.

Here is my answer to it, it maybe different scenario but i got this error.

I was creating a music player app and i had added the following library in my app gradle file.

implementation 'com.google.android.exoplayer:exoplayer:2.8.0'

I was following this tutorial for integrating ExoPlayer in my app. I changed this library version from 2.8.0 to 2.6.0 and it worked fine.

I hope this helps someone.

Whenever this error occurs just update buildtools and support dependencies to newer version.It will fix the issue. Keep in mind that all support dependencies should be same version

buildToolsVersion '28.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'

upload gradle!

classpath 'com.android.tools.build:gradle:3.3.1'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!