- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
将我的 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
}
应用分级
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.Manifest.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
无论如何都是父类(super class) Base
的子类。 Ctrl+click (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'
关于android - java.lang.NoSuchMethodError : No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47113948/
因为我遇到了问题 java.lang.NoSuchMethodError: No static method isCtrlPressed(Landroid/view/KeyEvent;) 并与 jav
好吧,这很奇怪。当我在模拟器中运行应用程序时,我的 logcat 突然发生崩溃,之前我从未遇到过它,并且自上次在模拟器中运行应用程序以来我没有对我的应用程序进行任何更改几周前,它正在运行。 这是完整的
我将 Android Studio 更新到 2.2,我的项目将不再构建。我的 Activity 的 super.onCreate(savedInstanceState) 给我一个错误: java.la
完全错误 java.lang.NoSuchMethodError: No static method asAttributeSet(Lt/g/a/a;)Landroid/util/AttributeS
查看我的日志 Java.Lang.NoSuchMethodError: no non-static method "Landroid/content/Context;.getColorStateLis
I updated my android studio to version 3.3 canary 13 (latest as of this writing). I was prompted
我在执行 App 时遇到了这种类型的错误。 我的代码在支持库 24.2.0(Linux 操作系统中的 Android studio)中运行,当我在 Windows 操作系统中运行这段代码时出现了一些错
我使用UniversalImageLoader(displayImage方法)来加载图像 但它抛出 NoSuchFieldException 异常: No field mMaxWidth in cla
这是我见过的最奇怪的错误,在我遇到数据库泄漏错误后,我通过使用静态实例解决了它,现在我的 Activity 崩溃了,但不是每次都崩溃,只有当我多次使用它并使用另一个 Activity 时回到它,它会崩
我想尝试来自 google ( https://developer.android.com/arch ) 的新生命周期内容,但在应用打开时崩溃。我所做的就是添加依赖项。还有其他人遇到这个问题吗? 日志
几个小时以来,我一直在努力解决这个问题。我尝试导入 2bard 的 AndroidPianoView作为一个库项目(PianoView 和 PianoViewExample 都在里面),它们都有一个
我尝试将应用程序的支持库从26.0.2更新为27.1.0,但遇到以下错误。 Gradle apply plugin: 'com.android.application' android { c
我正在慢慢地尝试学习 android,但我遇到了一个我不太明白的挂断。我正在尝试使用一些全局变量。我扩展了应用程序类。我在 list 中添加了我认为正确的内容(类的名称是 Fortune Crunch
我将我的 android studio 更新到版本 3.3 canary 13(撰写本文时为最新版本)。我被提示更新我的项目的 gradle 版本,我将它更新到版本 3.3.0-alpha13 类路径
我无法编译项目得到以下错误编译: 错误:任务 ':myApp:dexDebug' 执行失败。 com.android.ide.common.internal.LoggedErrorException:
我目前正在尝试使用 Retrofit2 设置 Room。我想将 Retrofit2 中的数据插入房间数据库,但插入对我不起作用,应用程序崩溃了。我使用 Room Library 实现了三个组件:实体、
真的找不到词,我的项目只是不从一天编译到另一天。 这就是我所做的: 我下载并显示一个 PDF,然后我将其作为保存的 PDF 打印到设备上,然后崩溃发生了。 这是崩溃: at java.lang.Cla
在谷歌上玩这个错误 FATAL EXCEPTION: main Process: com.sonymobile.scan3d, PID: 13877 java.lang.NoSuchMethodErr
我在多个论坛和相关答案中看到了这个错误,我尝试了所有但它似乎对我的情况不起作用。让我简单介绍一下我的环境。我正在使用 sunjdk 1.7 和 androidsdk 21 在 mac osx 10.7
1.每当我在我的应用程序中滑动查看下一张图片时,应用程序就会崩溃,我不知道出了什么问题 2.这个问题在更新到 Android 30 之后才正常工作 java.lang.NoSuchMethodErro
我是一名优秀的程序员,十分优秀!