con un normale android.app.AlertDialog
opere con ShadowAlertDialog.getLatestAlertDialog()
, ma se si utilizza una libreria di supporto android.support.v7.app.AlertDialog
, quindi questa eccezione accade:Robolectric InflateException quando si utilizza libreria di supporto v7 AlertDialog
android.view.InflateException: XML file app/build/intermediates/res/qa/debug/layout/abc_alert_dialog_material.xml line #-1 (sorry, not yet implemented): Error inflating class android.support.v7.internal.widget.DialogTitle
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:75)
at android.support.v7.app.AlertController.installContent(AlertController.java:216)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:240)
at android.app.Dialog.dispatchOnCreate(Dialog.java:361)
at android.app.Dialog.show(Dialog.java:262)
at org.robolectric.shadows.ShadowDialog.show(ShadowDialog.java:65)
at android.app.Dialog.show(Dialog.java)
<snip>
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -9
at java.lang.String.substring(String.java:1955)
at org.robolectric.res.ResName.qualifyResName(ResName.java:51)
at org.robolectric.res.Attribute.getStyleReference(Attribute.java:147)
at org.robolectric.res.builder.XmlFileBuilder$XmlResourceParserImpl.getResourceId(XmlFileBuilder.java:789)
Questo è un problema noto, ma qual è la migliore modo di risolvere il problema?
https://github.com/robolectric/robolectric/issues/1736