-1

So I am getting this error : android.content.ActivityNotFoundException: Unable to find explicit activity class {example.customkeyboard/android.view.Menu};

But it seems like the class is declared in AndroidManifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="example.keyboard">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Menu"
        android:label="@string/title_activity_menu"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".EditKeyboard"
        android:label="@string/title_activity_edit_keyboard"
        android:parentActivityName=".Menu"
        android:theme="@style/AppTheme.NoActionBar">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="example.keyboard.Menu" />
    </activity>
    <activity
        android:name=".KeyboardActivity"
        android:label="@string/title_activity_keyboard"
        android:parentActivityName=".Menu"
        android:theme="@style/AppTheme.NoActionBar">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="example.keyboard.Menu" />
    </activity>
</application>

</manifest>

method the causes this problem in MainActivity.java:

public void goToMenu(View view){
        startActivity(new Intent(this, Menu.class));
    }
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Ford O.
  • 1,394
  • 8
  • 25
  • 1
    You apparently have the `android.view.Menu` class imported in `MainActivity`, so you'll have to use the fully-qualified class name for your `Menu` `Activity` class - `example.keyboard.Menu`. Though it might be preferable to just change that class name; e.g., `MenuActivity`. – Mike M. Mar 21 '16 at 09:32

2 Answers2

0

As mentioned in comment by Mike,

you need to add fullyqualified name to solve this.

Press Ctrl+Alt+Shift+C on "Editor" code and you'll have the fully-qualified name in your clipboard.

Here it will be example.keyboard.Menu

Please check this link for more detail.

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
  • What should I do next time when I am creating activity, so I dont have to type the full path but use the keyword 'this' instead as I tried to? – Ford O. Mar 21 '16 at 11:12
  • when you create file in same package than you dont need to change path in AndroidMenifest file but you change package than use package.filename. – Amit Vaghela Mar 21 '16 at 11:15
  • Dont worry, once I get home and I test it I will accept – Ford O. Mar 21 '16 at 11:38
  • "when you create file in same package" Can you explain this to me a bit more? MainActivity.java and Menu.java both contain line: "package example.keyboard" so they should be in the same package right? Does some line in the manifest tell me that the package is different? – Ford O. Mar 21 '16 at 11:42
  • Oh I think I get it, I have overwritten the default android.view.Menu by my own Menu.java file, so the compiler doesnt know which of them I wanna use and therefore I have to either set the fully qualified name or change the Menu.java name. Is that right? – Ford O. Mar 21 '16 at 11:48
  • yes,you got it right. you must provide fullyqualified name or change path. – Amit Vaghela Mar 21 '16 at 11:53
  • inform me if still having issue. @FordO. – Amit Vaghela Mar 21 '16 at 12:28
0

It could be the cache problem. Renaming Activity fixed my issue.

Harish Kamboj
  • 887
  • 12
  • 32