[Android] ActivityNotFoundException com.android.settings.TextToSpeechSettings, have you declared this activity in your AndroidManifest.xml? 해결방법

[Android] ActivityNotFoundException com.android.settings.TextToSpeechSettings, have you declared this activity in your AndroidManifest.xml? 해결방법

구글파이어베이스에 오랜만에 로그인하여 오류보고서를 검토하였습니다.

몇 달 동안 쌓인 오류들을 확인하였고, 그 중에 눈에 띄는 새로운 오류가 보고 있었습니다.

이 오류는 구글 픽셀2폰(Pixel 2) 에서 발생된 것으로 확인되었습니다. 안드로이드 11이 설치된 폰입니다. 루팅된 폰도 아니군요.

자세한 오류 내용은 아래와 같아요.


Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manage.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.TextToSpeechSettings}; have you declared this activity in your AndroidManifest.xml? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.TextToSpeechSettings}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2065) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727) at android.app.Activity.startActivityForResult(Activity.java:5320) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676) at android.app.Activity.startActivityForResult(Activity.java:5278) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663) at android.app.Activity.startActivity(Activity.java:5664) at android.app.Activity.startActivity(Activity.java:5617) at com.manage.MainActivity.onCreate(MainActivity.java:303) at android.app.Activity.performCreate(Activity.java:8000) at android.app.Activity.performCreate(Activity.java:7984) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

아마도 안드로이드 11이 설치된 픽셀2폰에서는 TTS관련 설정 액티비티가 존재하지 않는 것일까요?

오류 방지를 위해 try-catch()문을 사용하여 다음과 같이 처리하였습니다.

public void callTTSettingClicked(View v){
	try {

		// Unable to find explicit activity class {com.android.settings/com.android.settings.TextToSpeechSettings}; have you declared this activity in your AndroidManifest.xml?
		//        ComponentName componentToLaunch = new ComponentName(
		//                "com.android.settings",
		//                "com.android.settings.TextToSpeechSettings");
		//        Intent intent = new Intent();
		//        intent.addCategory(Intent.CATEGORY_LAUNCHER);
		//        intent.setComponent(componentToLaunch);
		//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		//        startActivity(intent);

		Intent intent = new Intent();
		intent.setAction("com.android.settings.TTS_SETTINGS");
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(intent);

		//        Intent intent = new Intent();
		//        intent.addCategory(Intent.CATEGORY_LAUNCHER);
		//        intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.TextToSpeechSettings"));
		//        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		//        startActivity(intent);
	}catch (Exception e) {
		Toast.makeText(TTSActivity.this, getResources().getString(R.string.cont_24), Toast.LENGTH_LONG).show();
	}
}

[연관 자료]

https://stackoverflow.com/questions/12134210/starting-settings-activity-from-preferences-xml-works-in-2-x-but-not-in-4-x

완벽한 해결책은 없는 것일까??


카테고리의 다른 글
error: Content is protected !!