由于某些版本错误,Appcompat无法编译

时间:2018-01-20 14:35:49

标签: android android-appcompat

下面的

是我的gradle文件 ANDroid工作室正在显示此消息

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。发现版本27.0.2,26.1.0。示例包括com.android.support:support-compat:27.0.2和com.android.support:animated-vector-drawable:26.1。
申请插件:' com.android.application'

(1, 'xxx', 'y') 
(2, 'xxx', 'y') 
(3, 'xxx', 'y') 
(4, 'xxx', 'y') 
(5, 'xxx', 'y') 

当我运行应用程序时,应用程序在运行时崩溃,显示以下错误 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.example.tapesh.tapu_chat-2/base.apk)

2 个答案:

答案 0 :(得分:0)

我相信您正在使用构建工具版本26.0.2并且您正在使用一些支持依赖项。试试这个。

例如:

android {
    buildToolsVersion "26.0.2"

}

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'

}

答案 1 :(得分:0)

getFont()可以在Android“O”(26.0.0-beta1)版本

中使用

因此,请将构建工具版本更新为:"27.0.2"

示例:build.gradle

compileSdkVersion 27
buildToolsVersion "27.0.2"
targetSdkVersion 27

更新了依赖关系:

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