我在Crashlytics上得到了这份坠机报告:
SimpleMonthView.java line 684
android.widget.SimpleMonthView$MonthViewTouchHelper.getItemDescription
-----
Fatal Exception: java.util.IllegalFormatConversionException
%d can't format java.lang.String arguments
我看过这篇文章,但我不能在我的自定义课上做。
public class MyDatePickerDialog extends DialogFragment implements OnClickListener {
private static final String TAG = "DatePickerDialog";
public static LinearLayout dayMonth;
public static int maxMonth;
static int minYear;
static int maxYear;
static int id;
private static TextView dayTV;
private static TextView monthTV;
private static TextView yearTV;
private static TextView dayNameTV;
private static int mColor = 0;
private static GradientDrawable circle;
private static Typeface mTypeFace = null;
private static OnDateSetListener mCallBack;
private TextView doneTV;
private TextView cancelTV;
FragmentManager fragmentManager;
public MyDatePickerDialog() {
}
public static MyDatePickerDialog newInstance(OnDateSetListener onDateSetListener, int requestID) {
JDF jdf = new JDF();
return newInstance(onDateSetListener, requestID, jdf.getIranianYear(), jdf.getIranianMonth(), jdf.getIranianDay());
}
public static MyDatePickerDialog newInstance(OnDateSetListener onDateSetListener, boolean darkTheme) {
return newInstance(onDateSetListener, 0);
}
public static MyDatePickerDialog newInstance(OnDateSetListener onDateSetListener) {
return newInstance(onDateSetListener, 0);
}
public static MyDatePickerDialog newInstance(OnDateSetListener onDateSetListener, int requestID, int year, int month, int day) {
MyDatePickerDialog datePickerDialog = new MyDatePickerDialog();
mCallBack = onDateSetListener;
Date.setDate(year, month, day, false);
int thisYear = new JDF().getIranianYear();
datePickerDialog.setYearRange(thisYear, thisYear + 1);
id = requestID;
mColor = 0;
mTypeFace = null;
maxMonth = 0;
return datePickerDialog;
}
public static void updateDisplay(int year, int month, int day) {
try {
MyDatePickerDialog.dayTV.setText(String.valueOf(day));
MyDatePickerDialog.monthTV.setText(JDF.monthNames[month - 1]);
MyDatePickerDialog.yearTV.setText(String.valueOf(year));
MyDatePickerDialog.dayNameTV.setText(new JDF().getIranianDayName(year, month, day));
} catch (Exception e) {
Log.i(TAG, "updateDisplay -----> " + e);
}
}
@Override
public void onStart() {
setRetainInstance(true);
super.onStart();
}
@Override
public int getTheme() {
return super.getTheme();
}
private android.app.DatePickerDialog.OnDateSetListener dateSetListener() {
return new android.app.DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
}
};
}
@Override
public View onCreateView(LayoutInflater layoutInflater,
ViewGroup container, Bundle savedInstanceState) {
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
final View view = layoutInflater.inflate(R.layout.date_layout,
container, false);
if (mColor == 0)
try {
mColor = getResources().getColor(R.color.blue);
} catch (Resources.NotFoundException e) {
//Sentry MyLog.w(TAG, new Throwable().getStackTrace()[0].getLineNumber(), e);
e.printStackTrace();
}
circle = new GradientDrawable();
try {
circle.setCornerRadius(getResources().getDimension(
R.dimen.circle_radius));
circle.setColor(mColor);
circle.setAlpha(50);
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
fragmentManager = getChildFragmentManager();
dayTV = view.findViewById(R.id.day);
monthTV = view.findViewById(R.id.month);
yearTV = view.findViewById(R.id.year);
dayNameTV = view.findViewById(R.id.day_name);
doneTV = view.findViewById(R.id.done);
cancelTV = view.findViewById(R.id.cancel);
dayMonth = view.findViewById(R.id.dayMonthBack);
if (mTypeFace != null) {
dayTV.setTypeface(mTypeFace);
monthTV.setTypeface(mTypeFace);
yearTV.setTypeface(mTypeFace);
dayNameTV.setTypeface(mTypeFace);
doneTV.setTypeface(mTypeFace);
cancelTV.setTypeface(mTypeFace);
}
doneTV.setTextColor(mColor);
cancelTV.setTextColor(mColor);
view.findViewById(R.id.blue_card)
.setBackgroundColor(mColor);
dayMonth.setOnClickListener(this);
yearTV.setOnClickListener(this);
doneTV.setOnClickListener(this);
cancelTV.setOnClickListener(this);
updateDisplay(Date.getYear(), Date.getMonth(), Date.getDay());
view.findViewById(R.id.dayMonthBack).performClick();
return view;
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.year) {
dayTV.setAlpha(0.5f);
monthTV.setAlpha(0.5f);
yearTV.setAlpha(1f);
YearMainFragment yearMainFragment = new YearMainFragment();
switchFragment(yearMainFragment.yearMainFragement(minYear, maxYear));
} else if (v.getId() == R.id.dayMonthBack) {
dayTV.setAlpha(1f);
monthTV.setAlpha(1f);
yearTV.setAlpha(0.5f);
switchFragment(new MonthMainFragment());
} else if (v.getId() == R.id.done) {
if (mCallBack != null) {
Calendar calendar = Calendar.getInstance();
JDF j = new JDF();
j.setIranianDate(Date.getYear(), Date.getMonth(), Date.getDay());
try {
calendar = j.getGregorianCalendar(Date.getYear(),
Date.getMonth(), Date.getDay());
} catch (Exception e) {
Log.i(TAG, "-----> Exception onClosedItemClick: " + e);
}
mCallBack.onDateSet(id, calendar, Date.getYear(), Date.getMonth(), Date.getDay(), dayNameTV.getText().toString());
}
dismissAllowingStateLoss();
} else if (v.getId() == R.id.cancel) {
dismissAllowingStateLoss();
}
}
void switchFragment(final Fragment fragment) {
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.frame_container, fragment);
transaction.addToBackStack(null);
try {
transaction.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
/* ---------- Getters & Setters ---------- */
public static GradientDrawable getCircle() {
return circle;
}
public static int getColor() {
return mColor;
}
public static Typeface getTypeFace() {
return mTypeFace;
}
public void setTypeFace(Typeface typeface) {
mTypeFace = typeface;
}
public static int getRequestID() {
return id;
}
public void setRequestID(int requestID) {
id = requestID;
}
public void setMainColor(int color) {
mColor = color;
}
public void setYearRange(int _minYear, int _maxYear) {
minYear = _minYear;
maxYear = _maxYear;
}
public void setInitialDate(int year, int month, int day) {
Date.setDate(year, month, day, false);
}
public void setInitialDate(Calendar calendar) {
JDF jdf = new JDF();
jdf.setGregorianDate(calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH) + 1,
calendar.get(Calendar.DAY_OF_MONTH));
Date.setDate(jdf.getIranianYear(), jdf.getIranianMonth(),
jdf.getIranianDay(), false);
}
public void setFutureDisabled(Boolean disabled) {
if (disabled) {
JDF jdf = new JDF();
maxMonth = jdf.getIranianMonth() - 11;
maxYear = jdf.getIranianYear();
if (minYear > maxYear)
minYear = maxYear - 1;
if (Date.getMonth() > jdf.getIranianMonth())
Date.setMonth(jdf.getIranianMonth());
if (Date.getDay() > jdf.getIranianDay())
Date.setDay(jdf.getIranianDay());
if (Date.getYear() > jdf.getIranianYear())
Date.setYear(jdf.getIranianYear());
} else
maxMonth = 0;
}
/* ---------- End of Getters & Setters ---------- */
public interface OnDateSetListener {
void onDateSet(int id, Calendar calendar, int year,
int month, int day, String dayName);
}
}
我怎样才能解决这个问题?
StackTrace:
# OS Version: 5.1.1
# Device: Galaxy Core Prime
# RAM Free: 38.8%
# Disk Free: 12.8%
#0. Crashed: main
at java.util.Formatter.badArgumentType + 1489(Formatter.java:1489)
at java.util.Formatter.transformFromInteger + 1689(Formatter.java:1689)
at java.util.Formatter.transform + 1461(Formatter.java:1461)
at java.util.Formatter.doFormat + 1081(Formatter.java:1081)
at java.util.Formatter.format + 1042(Formatter.java:1042)
at java.util.Formatter.format + 1011(Formatter.java:1011)
at java.lang.String.format + 1803(String.java:1803)
at android.content.res.Resources.getString + 668(Resources.java:668)
at android.content.Context.getString + 390(Context.java:390)
at android.widget.SimpleMonthView$MonthViewTouchHelper.getItemDescription + 684(SimpleMonthView.java:684)
at android.widget.SimpleMonthView$MonthViewTouchHelper.onPopulateNodeForVirtualView + 628(SimpleMonthView.java:628)
at com.android.internal.widget.ExploreByTouchHelper.createNodeForChild + 397(ExploreByTouchHelper.java:397)
at com.android.internal.widget.ExploreByTouchHelper.createNode + 324(ExploreByTouchHelper.java:324)
at com.android.internal.widget.ExploreByTouchHelper.access$100 + 49(ExploreByTouchHelper.java:49)
at com.android.internal.widget.ExploreByTouchHelper$ExploreByTouchNodeProvider.createAccessibilityNodeInfo + 741(ExploreByTouchHelper.java:741)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos + 805(AccessibilityInteractionController.java:805)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread + 155(AccessibilityInteractionController.java:155)
at android.view.AccessibilityInteractionController.access$400 + 53(AccessibilityInteractionController.java:53)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage + 1146(AccessibilityInteractionController.java:1146)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 135(Looper.java:135)
at android.app.ActivityThread.main + 5910(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1405(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main + 1200(ZygoteInit.java:1200)
--
Fatal Exception: java.util.IllegalFormatConversionException: %d can't format java.lang.String arguments
at java.util.Formatter.badArgumentType + 1489(Formatter.java:1489)
at java.util.Formatter.transformFromInteger + 1689(Formatter.java:1689)
at java.util.Formatter.transform + 1461(Formatter.java:1461)
at java.util.Formatter.doFormat + 1081(Formatter.java:1081)
at java.util.Formatter.format + 1042(Formatter.java:1042)
at java.util.Formatter.format + 1011(Formatter.java:1011)
at java.lang.String.format + 1803(String.java:1803)
at android.content.res.Resources.getString + 668(Resources.java:668)
at android.content.Context.getString + 390(Context.java:390)
at android.widget.SimpleMonthView$MonthViewTouchHelper.getItemDescription + 684(SimpleMonthView.java:684)
at android.widget.SimpleMonthView$MonthViewTouchHelper.onPopulateNodeForVirtualView + 628(SimpleMonthView.java:628)
at com.android.internal.widget.ExploreByTouchHelper.createNodeForChild + 397(ExploreByTouchHelper.java:397)
at com.android.internal.widget.ExploreByTouchHelper.createNode + 324(ExploreByTouchHelper.java:324)
at com.android.internal.widget.ExploreByTouchHelper.access$100 + 49(ExploreByTouchHelper.java:49)
at com.android.internal.widget.ExploreByTouchHelper$ExploreByTouchNodeProvider.createAccessibilityNodeInfo + 741(ExploreByTouchHelper.java:741)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos + 805(AccessibilityInteractionController.java:805)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread + 155(AccessibilityInteractionController.java:155)
at android.view.AccessibilityInteractionController.access$400 + 53(AccessibilityInteractionController.java:53)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage + 1146(AccessibilityInteractionController.java:1146)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 135(Looper.java:135)
at android.app.ActivityThread.main + 5910(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1405(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main + 1200(ZygoteInit.java:1200)
#0. Crashed: main
at java.util.Formatter.badArgumentType + 1489(Formatter.java:1489)
at java.util.Formatter.transformFromInteger + 1689(Formatter.java:1689)
at java.util.Formatter.transform + 1461(Formatter.java:1461)
at java.util.Formatter.doFormat + 1081(Formatter.java:1081)
at java.util.Formatter.format + 1042(Formatter.java:1042)
at java.util.Formatter.format + 1011(Formatter.java:1011)
at java.lang.String.format + 1803(String.java:1803)
at android.content.res.Resources.getString + 668(Resources.java:668)
at android.content.Context.getString + 390(Context.java:390)
at android.widget.SimpleMonthView$MonthViewTouchHelper.getItemDescription + 684(SimpleMonthView.java:684)
at android.widget.SimpleMonthView$MonthViewTouchHelper.onPopulateNodeForVirtualView + 628(SimpleMonthView.java:628)
at com.android.internal.widget.ExploreByTouchHelper.createNodeForChild + 397(ExploreByTouchHelper.java:397)
at com.android.internal.widget.ExploreByTouchHelper.createNode + 324(ExploreByTouchHelper.java:324)
at com.android.internal.widget.ExploreByTouchHelper.access$100 + 49(ExploreByTouchHelper.java:49)
at com.android.internal.widget.ExploreByTouchHelper$ExploreByTouchNodeProvider.createAccessibilityNodeInfo + 741(ExploreByTouchHelper.java:741)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos + 805(AccessibilityInteractionController.java:805)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread + 155(AccessibilityInteractionController.java:155)
at android.view.AccessibilityInteractionController.access$400 + 53(AccessibilityInteractionController.java:53)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage + 1146(AccessibilityInteractionController.java:1146)
at android.os.Handler.dispatchMessage + 102(Handler.java:102)
at android.os.Looper.loop + 135(Looper.java:135)
at android.app.ActivityThread.main + 5910(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1405(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main + 1200(ZygoteInit.java:1200)
三星的Lollipop实现中有一个bug。如果启用了对讲,则在某些区域设置中会发生这种情况。您可以通过在带有Holo主题的三星设备上强制使用DatePicker来修复。
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isBrokenSamsungDevice())
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Holo_Light_Dialog);
}
private static boolean isBrokenSamsungDevice() {
return (Build.MANUFACTURER.equalsIgnoreCase("samsung")
&& isBetweenAndroidVersions(
Build.VERSION_CODES.LOLLIPOP,
Build.VERSION_CODES.LOLLIPOP_MR1));
}
private static boolean isBetweenAndroidVersions(int min, int max) {
return Build.VERSION.SDK_INT >= min && Build.VERSION.SDK_INT <= max;
}
好的,所以这段代码在任何其他设备上都能正常工作,但在三星设备上会崩溃。我似乎不知道为什么,但我知道如果我使用TextView,它不会崩溃。但问题是,我需要这个字段的EditText,它可以包含多个链接。我花了一天的时间寻找一个没有用的解决方案,所以我想我应该在这里发布: 注意:这在我测试的Nexus和Motorola设备上似乎很有效:我想三星在处理EditText框中的链接时,有没有遗漏一些解决方
我们从Galaxy S6、Android 5.0.2的测试人员那里得到了这个崩溃。Android系统WebView37 (1726107-arm64)Google Play服务19.0.56 (020400-263933554)谷歌应用商店16.5.30-all[0][PR] 267441717 如何复制(除了上述设备): Android Studio,为x86_64api 21和22构建的模拟器
自过去2个月以来,我们开始在开发人员控制台中接收到仅适用于部分三星设备的本机崩溃。 这是车祸痕迹 这是迄今为止收到崩溃的设备列表- 你知道为什么会这样吗? 这是构建。格拉德尔
在React Native中,我为所有使用Rubik字体的文本定义了字体系列,但某些设备(三星 我不知道为什么有时有些文本看起来像是用自定义设备字体覆盖 环境: 操作系统:macOS HighSierra 节点:9.3.0 纱线:1.3.2 npm:5.7.0 守望者:4.9.0 包: react-native: “^0.47.2, 反应: “^16.0.0-alpha.12, react-nat
下面是我的DialogFragment代码: 下面是相关的xml布局: 事实上,我有两种问题(导致应用程序崩溃): null