Po aktualizacji oprogramowania Android Studio do 3.0 pojawia się błąd No static method getFont()
. Projekt, w którym pracuję jest na github, https://github.com/ik024/GithubBrowserjava.lang.NoSuchMethodError: Brak statycznej metody getFont (Landroid/content/Context, ILandroid/util/TypedValue; ILandroid/widget/TextView;)
// Top-level build file where you can add configuration options common
to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
ext{
arch_version = "1.0.0-alpha9"
support_version = "26.0.2"
dagger_version = "2.11"
junit_version = "4.12"
espresso_version = "2.2.2"
retrofit_version = "2.3.0"
mockwebserver_version = "3.8.0"
apache_commons_version = "2.5"
mockito_version = "1.10.19"
constraint_layout_version = "1.0.2"
timber_version = "4.5.1"
butterknife_version = "9.0.0-SNAPSHOT"
rxbinding_version = "2.0.0"
retrofit_version = "2.3.0"
okhttp_version = "3.6.0"
rxjava2_adapter_version = "1.0.0"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
aplikacja Gradle
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.ik.githubbrowser"
minSdkVersion 17
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'
}
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
testOptions {
unitTests.returnDefaultValues = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support.constraint:constraint-layout:$constraint_layout_version"
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:recyclerview-v7:$support_version"
compile "com.android.support:cardview-v7:$support_version"
compile "com.android.support:design:$support_version"
compile "com.android.support:support-v4:$support_version"
compile "android.arch.persistence.room:runtime:$arch_version"
compile "android.arch.lifecycle:runtime:$arch_version"
compile "android.arch.lifecycle:extensions:$arch_version"
compile "android.arch.persistence.room:rxjava2:$arch_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
compile "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:$rxjava2_adapter_version"
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
compile "com.jakewharton.timber:timber:$timber_version"
compile "com.jakewharton:butterknife:$butterknife_version"
compile "com.jakewharton.rxbinding2:rxbinding:$rxbinding_version"
compile "com.google.dagger:dagger:$dagger_version"
compile "com.google.dagger:dagger-android:$dagger_version"
compile "com.google.dagger:dagger-android-support:$dagger_version"
testCompile "junit:junit:$junit_version"
testCompile "com.squareup.okhttp3:mockwebserver:$mockwebserver_version"
testCompile("android.arch.core:core-testing:$arch_version", {
exclude group: 'com.android.support', module: 'support-compat'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-core-utils'
})
androidTestCompile "com.android.support:appcompat-v7:$support_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
exclude group: 'com.android.support', module: 'support-core-ui'
}
androidTestCompile "com.android.support:recyclerview-v7:$support_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
exclude group: 'com.android.support', module: 'support-core-ui'
}
androidTestCompile "com.android.support:support-v4:$support_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
exclude group: 'com.android.support', module: 'support-core-ui'
}
androidTestCompile "com.android.support:design:$support_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
exclude group: 'com.android.support', module: 'support-core-ui'
}
androidTestCompile("com.android.support.test.espresso:espresso-core:$espresso_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$espresso_version", {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
exclude group: 'com.android.support', module: 'support-fragment'
exclude group: 'com.android.support', module: 'support-core-ui'
})
androidTestCompile("android.arch.core:core-testing:$arch_version", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'org.mockito:mockito-android:2.7.15', {
exclude group: 'com.android.support', module: 'support-annotations'
}
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
annotationProcessor "android.arch.persistence.room:compiler:$arch_version"
annotationProcessor "android.arch.lifecycle:compiler:$arch_version"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife_version"
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
}
Błąd:
FATAL EXCEPTION: main Process: com.ik.githubbrowser, PID: 4248 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.ik.githubbrowser-YvwoGrxR8QaUEZ3IEqFVLQ==/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.(AppCompatTextView.java:81) at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71) at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:67) at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:753) at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261) at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243) at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:621) at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:631) at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.ik.githubbrowser.ui.search_user.SearchUserActivity.onCreate(SearchUserActivity.java:49) at android.app.Activity.performCreate(Activity.java:6975) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Thanks to rozwiązać dla mnie. Czy to oznacza, że buildToolVersion 26.0.2 ma błąd? – ik024
Myślę, że tak! Próbowałem z 26.0.2, ale to nie działa – Nawrez
Dzięki! To działa na mnie. –