Android - Activity Not Found Exception

前端 未结 13 1791
春和景丽
春和景丽 2020-11-30 10:05

I am using startActivity to call another Activity and I get the \"Activity Not Found Exception\". Here is my code:

  TextView textView = (TextView) itemClic         


        
相关标签:
13条回答
  • 2020-11-30 10:25

    Try adding activity to AndroidManifest.xml

    <activity android:name=".MyActivity" />
    
    0 讨论(0)
  • 2020-11-30 10:25

    Not only need you add your Activity in AndroidMainifest.xml like this:

    <activity 
            android:name=".MyActivity"
           ></activity>
    

    but also you should confirm your package path.

    For example,my activity is in com.demo package. The head of the AndroidMainifest should write the same package path,like this:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.demo"
       android:versionCode="1"
       android:versionName="1.0" >
    
    0 讨论(0)
  • 2020-11-30 10:26
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.salvopaverani.databes"
    android:versionCode="1"
    android:versionName="1.1" >
    

    At manifest file, i try to change the android:versionName from 1.0 to 1.1 and everything OK.

    0 讨论(0)
  • 2020-11-30 10:29

    I was trying to start SERVICE with startActivity(intent) and the same exception popped out. To run SERVICE, use startService(intent)

    0 讨论(0)
  • 2020-11-30 10:29

    In addition to the answer which Unfrog has given.

    One way to get the NullPointerException is to execute a code which is referring to the view parts before the setContentView().

    0 讨论(0)
  • 2020-11-30 10:30

    Stuck with the same error for an hour only to realize that I have to clean and build again. Apparently, some times changes in xml do not reflect until we clean and rebuild.

    0 讨论(0)
提交回复
热议问题