Gaurav Mishra
Gaurav Mishra

Reputation: 11

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

I don't understand what went wrong exactly somebody plz help.

it gives me java.lang.RuntimeException: Unable to start activity ComponentInfo

please, be exact to point as I am new to android. thank you in advance.

Here is my LogCat

    FATAL EXCEPTION: main
              Process: com.example.gaurav.comfortzone, PID: 8282
              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.gaurav.comfortzone-2/split_lib_dependencies_apk.apk)
                  at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)
                  at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)
                  at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:110)
                  at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
                  at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:81)
                  at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:71)
                  at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
                  at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024)
                  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
                  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                  at com.example.gaurav.comfortzone.LoginActivity.onCreate(LoginActivity.java:23)
                  at android.app.Activity.performCreate(Activity.java:6679)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                  at android.app.ActivityThread.-wrap12(ActivityThread.java)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:154)
                  at android.app.ActivityThread.main(ActivityThread.java:6119)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Here is my build.gradle (module app)

    android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
    applicationId "com.example.gaurav.comfortzone"
    minSdkVersion 16
    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 {
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'
})
//Add library
    compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support:cardview-v7:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.firebaseui:firebase-ui-database:3.2.1'
compile 'com.android.support:design:26.0.2'
//compile 'com.android.support:support-v13:26.1.0'

testCompile 'junit:junit:4.12'
    }
    apply plugin: 'com.google.gms.google-services'

please HELP ME.... i am new to android i dont understand where i went wrong.

Upvotes: 0

Views: 2169

Answers (2)

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29794

Your code is using ResourcesCompat.getFont() which is only available since support library version 26.1.0. So, you need to update all your support library to at least version 26.1.0.

dependencies {
    ...
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    ...
}

Upvotes: 0

Perraco
Perraco

Reputation: 17380

Your log shows that there is a problem inflating your layout XML due to an issue with info.hoang8f:fbutton.

Look at the next line in your log:

Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton

And the reason why Fbutton seems to be failing:

java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
              at android.content.res.TypedArray.getColor(TypedArray.java:463)

So the best is to check why is failing to inflate the mentioned FButton, which by your gradle file clearly is a third-party library.

UPDATE:

I see you have changed the stack-trace of your original question for a new different one. First of all, please don't do that because you are completely changing your question, which makes the answer no longer relevant and/or not usable to other developers which could face a similar issue. Please follow the StackOverflow guidelines. You should instead edit your question and append the log as an update, or to ask a new different question.

Regarding the new problem, please look at the next answer:

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

Upvotes: 1

Related Questions