Nexus 5エミュレータ(API 24/Google API)でコードを実行しようとすると、上記の例外が発生します...Android - java.lang.reflect.InvocationTargetExceptionを呼び出すdialog.show()
E/ACRA: ACRA caught a RuntimeException for com.example
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.SplashActivity}: android.view.InflateException: Binary XML file line #25: Binary XML file line #44: Error inflating class com.android.internal.widget.DialogTitle
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.view.InflateException: Binary XML file line #25: Binary XML file line #44: Error inflating class com.android.internal.widget.DialogTitle
Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class com.android.internal.widget.DialogTitle
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:414)
at com.android.internal.app.AlertController.installContent(AlertController.java:236)
at android.app.AlertDialog.onCreate(AlertDialog.java:423)
at android.app.Dialog.dispatchOnCreate(Dialog.java:389)
at android.app.Dialog.show(Dialog.java:293)
at com.example.SplashActivity.checkPlayServices(SplashActivity.java:195)
at com.example.SplashActivity.onCreate(SplashActivity.java:74)
at android.app.Activity.performCreate(Activity.java:6664)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:528)
at android.widget.TextView.<init>(TextView.java:783)
at android.widget.TextView.<init>(TextView.java:704)
at android.widget.TextView.<init>(TextView.java:700)
E/ACRA: at com.android.internal.widget.DialogTitle.<init>(DialogTitle.java:41)
... 34 more
は、私はむしろgetApplicationContext()
を渡すよりも、ダイアログのコンストラクタにSplashActivity.this
を渡すことをお勧め類似した質問の回答を見て - しかし、私はすでに活動のインスタンスを渡しています。
何が間違っている可能性がありますか?
私のコード!...ダウン以下
private boolean checkPlayServices() {
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(this);
if (result != ConnectionResult.SUCCESS) {
if (googleAPI.isUserResolvableError(result)) {
Dialog dialog = googleAPI.getErrorDialog(this, result, PLAY_SERVICES_RESOLUTION_REQUEST);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
SplashActivity.this.finish();
}
});
dialog.show();
}
return false;
}
return true;
}
xmlレイアウトでは何かがサポートされていません。 – njzk2
あなたのXMLレイアウトを投稿してください。問題は、com.android.internal.widget.DialogTitleを膨らませることです。 –
私のコードを今追加しました。ご覧のとおり、「GoogleApiAvailability」からエラーダイアログが表示されるので、レイアウトファイルについては何も言わないでください。 –