尝试以编程方式重新启动应用程序时获取NoSuchMethodException createFromFamiliesWithDefault

时间:2018-09-30 11:10:30

标签: android

我正在尝试将阿拉伯语添加到当前应用程序中。当用户选择一种语言时,我将使用帮助程序类更改语言环境并重新启动应用程序。

     String languageCode = data.getStringExtra(BundleKey.SELECTED_LANGUAGE);
     LocaleHelper.setLocale(this, languageCode);
     recreateActivity();

这是recreateActivity()方法

protected void recreateActivity() {
    Intent startActivity = new Intent(getApplicationContext(), SplashScreenActivity.class);
    int pendingIntentId = 123456;
    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), pendingIntentId, startActivity, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    if (alarmManager != null) {
        alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + 100, pendingIntent);
        System.exit(0);
    }
}

一切都可以在我的物理设备(6.0.1)上正常运行,但是在Nexus 6 API P上却出现错误:

2018-09-30 13:58:44.865 4653-4653/com.mobile.justmop E/TypefaceCompatApi26Impl: Unable to collect necessary methods for class java.lang.NoSuchMethodException
java.lang.NoSuchMethodException: createFromFamiliesWithDefault [class [Landroid.graphics.FontFamily;, int, int]
    at java.lang.Class.getMethod(Class.java:2068)
    at java.lang.Class.getDeclaredMethod(Class.java:2047)
    at android.support.v4.graphics.TypefaceCompatApi26Impl.<clinit>(TypefaceCompatApi26Impl.java:93)
    at android.support.v4.graphics.TypefaceCompat.<clinit>(TypefaceCompat.java:50)
    at android.support.v4.graphics.TypefaceCompat.findFromCache(TypefaceCompat.java:89)
    at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:368)
    at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java:336)
    at android.support.v4.content.res.ResourcesCompat.getFont(ResourcesCompat.java:314)
    at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:118)
    at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:234)
    at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:165)
    at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:82)
    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:72)
    at android.support.v7.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:176)
    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:101)
    at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
    at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    at com.mobile.***.ui.settings.activity.SettingsActivity.onCreate(SettingsActivity.java:58)
    at android.app.Activity.performCreate(Activity.java:7117)
    at android.app.Activity.performCreate(Activity.java:7108)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1262)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2867)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3027)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:101)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

0 个答案:

没有答案