错误java.lang.NoSuchMethodError:没有静态方法 [英] Error java.lang.NoSuchMethodError: No static method

查看:1136
本文介绍了错误java.lang.NoSuchMethodError:没有静态方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从下面的git链接运行代码

I'm trying to run code from git link below

https://github.com/Mikhail57/RetrofitTutorial

但是我遇到错误


java.lang.NoSuchMethodError:没有静态方法getFont(Landroid / content / Context; ILandroid / util / TypedValue; ILandroid / widget / TextView;)Landroid / graphics / Typeface;在类Landroid / support / v4 / content / res / ResourcesCompat中;或其超级类( android.support.v4.content.res.ResourcesCompat的声明出现在/data/app/com.stanlytango.android.secondfromgitretrofit-aDuaUJp0_br091ehbTa3bQ == / split_lib_dependencies_apk.apk)

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.stanlytango.android.secondfromgitretrofit-aDuaUJp0_br091ehbTa3bQ==/split_lib_dependencies_apk.apk)

我的应用程序build.gradle

My app build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.stanlytango.android.secondfromgitretrofit"
        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.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'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
}

activity_main布局

activity_main layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.stanlytango.android.secondfromgitretrofit.MainActivity">

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:id="@+id/posts_recycle_view"
        android:layout_alignParentStart="true" />
</RelativeLayout>

请有人可以帮助我解决该问题。非常感谢!

Please can anybody help me to resolve it. Thanks a lot!

推荐答案

使用此

compileSdkVersion 27.0.2
buildToolsVersion '27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'

而不是这个

compileSdkVersion 26
implementation 'com.android.support:appcompat-v7:26.1.0'

这篇关于错误java.lang.NoSuchMethodError:没有静态方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆