【发布时间】:2018-07-28 15:48:46
【问题描述】:
考虑:
buildscript {
repositories {
apply plugin: 'announce'
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories
{
google()
jcenter()
maven{ url "https://jitpack.io"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle(可能是这里出错的原因)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "chocolahat.softeng.sweetbitescafe"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
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'
// My Library
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-database:11.6.2'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.android.support:recyclerview-v7:26.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:3.1.2'
implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.android.support:design:26.+'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.google.android.gms:play-services-location:11.6.2'
implementation 'com.github.mancj:MaterialSearchBar:0.7.1'
implementation 'com.github.d-max:spots-dialog:0.7@aar'
}
apply plugin: 'com.google.gms.google-services'
错误(不幸的是应用程序已停止)
E/AndroidRuntime: 致命异常: main 进程:chocolahat.softeng.sweetbitescafe,PID:26876 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/chocolahat.softeng.sweetbitescafe-2/split_lib_dependencies_apk.apk 中) 在 android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119) 在 android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208) 在 android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:110) 在 android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38) 在 android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81) 在 android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71) 在 android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103) 在 android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024) 在 android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081) 在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725) 在 android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 在 android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:504) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:414) 在 android.view.LayoutInflater.inflate(LayoutInflater.java:365) 在 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 在 android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 在 chocolahat.softeng.sweetbitescafe.MainActivity.onCreate(MainActivity.java:18) 在 android.app.Activity.performCreate(Activity.java:6092) 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2608) 在 android.app.ActivityThread.access$800(ActivityThread.java:178) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 在 android.os.Handler.dispatchMessage(Handler.java:111) 在 android.os.Looper.loop(Looper.java:194) 在 android.app.ActivityThread.main(ActivityThread.java:5637) 在 java.lang.reflect.Method.invoke(本机方法) 在 java.lang.reflect.Method.invoke(Method.java:372) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
MainActivity.java:18 行代码是这样的 setContentView(R.layout.activity_main);
我该如何解决这个问题?
【问题讨论】:
-
定义或声明任何自定义字体属性?
-
显示您使用的是自定义文本视图,而您提供的字体路径无效。
-
那我该怎么办?
-
请发布您的自定义视图代码
-
有什么解决办法吗?
标签: java android android-studio