java.lang.NoSuchMethodError : 정적 메소드 없음 getFont (Landroid / content / Context; ILandroid / util / TypedValue; ILandroid / widget / TextView;)
Android Studio를 3.0으로 업데이트 한 후 No static method getFont()
오류 가 발생합니다. 제가 작업중인 프로젝트는 github, https://github.com/ik024/GithubBrowser에 있습니다.
// 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
}
앱 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'
}
오류:
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)
res / values / styles.xml 및 Manifest.xml을 다음 과 같이 수정합니다 .이 솔루션은 테스트되었으며 정리하고 빌드하는 것을 잊지 마십시오.
1. 매니페스트 .xml
HomeActivity의 테마를 다음과 같이 변경하십시오.
<activity
android:name=".ui.home.HomeActivity"
android:theme="@style/Base.Theme.AppCompat.Light" />
<activity android:name=".BaseActivity"></activity>
2. res / values / styles.xml Base : styles.xml로 시작하는 모든 테마를 다음과 같이 만듭니다.
<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" />
요청에 따른 자세한 설명 : 어쨌든 Theme.AppCompat.Light.DarkActionBar
수퍼 클래스의 하위 클래스 Base
입니다. Ctrl + 클릭 (Android Studio)하면 소스로 이동합니다.
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />
3. GithubBrowser-Master.gradle
만들지 support_version = "27.0.0"
말고support_version = "26.0.2
4. app.gradle :
compileSdkVersion 27
buildToolsVersion '27.0.0'
그리고 아닙니다
compileSdkVersion 26
buildToolsVersion '26.0.2'
이것은 나를 위해 일합니다.
buildToolsVersion "27.0.3"
과
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'
}
내 경우에는, 내가 사용하던 안드로이드 KTX를 : implementation 'androidx.core:core-ktx:0.1'
에 코 틀린의 프로젝트, 그 오류의 원인이었다. 방금 build.gradle 에서 종속성으로 제거했습니다 .
나는 또한이 문제가 있었고 응용 프로그램 gradle 파일을 설정 하여이 문제를 해결했습니다.
컴파일 sdk 버전을 27로 변경하고 buildToolsVersion을 27.0.3으로 변경하십시오.
compileSdkVersion 27
buildToolsVersion '27 .0.3 '
27.1.1 버전 지원 라이브러리를 추가합니다.
'com.android.support:recyclerview-v7:27.1.1'컴파일
'com.android.support:cardview-v7:27.1.1'컴파일
'com.android.support:appcompat-v7:27.1.1'컴파일
그런 다음 프로젝트를 동기화하십시오.
그게 다야.
comileSdkVersion과 targetSdkVersion이 같아야합니다.
또한 종속성을 최신 버전으로 업데이트하고 프로젝트를 동기화하고 실행하십시오. 문제를 해결하는 데 도움이되었습니다.
나는 같은 문제가 있었고 appcompat와 디자인을 변경하고 recyclerview를 다음 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'
다시 gradle 동기화
compileSdkVersion 26은 때때로이 오류를 제공합니다. 이를 해결하려면 app.gradle 파일에서 compileSdkVersion 및 targetSdkVersion을 27로 업그레이드하십시오. 또한 종속성 섹션에서 해당 종속성을 변경하십시오. 이를 위해 buildToolsVersion을 지정할 필요가 없습니다.
모든 종속성의 버전은 compileSdkVersion과 동일해야합니다. 그래서 build.gradle (module)의 코드 아래에서 작동합니다.
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'
...
제 경우에는 Glide 와 Appcompat 라이브러리 의 조합으로 인해이 문제가 발생했습니다 (버전이 서로를 지원하지 않음).
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'
내 앱에 ExoPlayer를 통합 하기 위해이 튜토리얼 을 따랐습니다. 이 라이브러리 버전을 2.8.0에서 2.6.0으로 변경했는데 제대로 작동했습니다.
누군가에게 도움이되기를 바랍니다.
이 오류가 발생할 때마다 buildtools를 업데이트하고 최신 버전에 대한 종속성을 지원하면 문제가 해결됩니다. 모든 지원 종속성은 동일한 버전이어야합니다.
buildToolsVersion '28.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
gradle 업로드!
클래스 경로 'com.android.tools.build:gradle:3.3.1'
'development' 카테고리의 다른 글
Microsoft Edge의 사용자 에이전트 문자열 이름은 무엇입니까? (0) | 2020.12.11 |
---|---|
Swift에서 환경 변수 참조 (0) | 2020.12.11 |
비활성화 된 TextBox의 글꼴 색상을 변경하는 방법은 무엇입니까? (0) | 2020.12.11 |
개체 컬렉션 정렬 (0) | 2020.12.11 |
내 앱에서 직접 "iTunes에서 평가"링크를 사용합니까? (0) | 2020.12.11 |