Iyke
Iyke

Reputation: 47

How do I resolve Activity Not Found Exception

In my android app, I've added an activity MainActivity in the manifest file, on navigating to that activity using an inten I get activity not found error asking if I've added it to manifest

here is my manifest activity

        <activity
            android:name=".MainActivity"
            android:clearTaskOnLaunch="true"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:icon="@mipmap/ic_launcher"
            android:rotationAnimation="seamless"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat"
            tools:targetApi="O">

             <intent-filter>
             <action android:name="android.intent.action.MAIN" />


             <category android:name="android.intent.category.OPENABLEk" />
             </intent-filter>

<!--            Register as a system camera app-->
            <intent-filter>
                <action android:name="android.media.action.IMAGE_CAPTURE" />
                <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
                <action android:name="android.media.action.VIDEO_CAMERA" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <!-- App links for http/s -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:host="example.android.com" />
                <data android:pathPattern="/camerax" />
            </intent-filter>

            <!-- Declare notch support -->
            <meta-data
                android:name="android.notch_support"
                android:value="true" />
        </activity>

here is the log

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.virtusync.scanningtool, PID: 28538
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.virtusync.scanningtool/com.android.example.cameraxbasic.MainActivityKt}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
        at android.app.Activity.startActivityForResult(Activity.java:4586)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675)
        at android.app.Activity.startActivityForResult(Activity.java:4544)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662)
        at android.app.Activity.startActivity(Activity.java:4905)
        at android.app.Activity.startActivity(Activity.java:4873)
        at com.android.example.cameraxbasic.SelectOperation$1.onClick(SelectOperation.java:36)
        at android.view.View.performClick(View.java:7044)
        at android.view.View.performClickInternal(View.java:7017)
        at android.view.View.access$3200(View.java:784)
        at android.view.View$PerformClick.run(View.java:26596)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6819)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)

I've done this How to fix "android.content.ActivityNotFoundException" android-studio 2.3.3 no solution yet

Upvotes: -2

Views: 1345

Answers (2)

Themelis
Themelis

Reputation: 4245

The error message says it all,

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.virtusync.scanningtool/com.android.example.cameraxbasic.MainActivityKt}; have you declared this activity in your AndroidManifest.xml?

From what it seems in your manifst, you haven't.

The only activity declared is MainActivity

<activity
     android:name=".MainActivity"
     ...

The exception was raised because in your code you are using a class that is named MainActivityKt.

Probably you mispelled that name, fix it.

Upvotes: 3

Simon Libbs
Simon Libbs

Reputation: 103

Did you rename your activity? The Error Message says "MainActivityKt" not found, but the Activity in your Manifest File is called "MainActivity".

Rename the activity in your Manifest or the Java class.

Upvotes: 0

Related Questions