Could not identify launch Activity: Default Activity not found

前端 未结 9 860
一生所求
一生所求 2020-12-05 23:56

I\'m new to android and I have encounterded a problem. The console said that \"Could not identify launch activity: Default Activity not found\". I have add

         


        
相关标签:
9条回答
  • 2020-12-06 00:41

    If you see that error occur after upgrading your IDEA, upgrading Android Studio version, or Generating a new APK, you may need to refresh the IDE's cache.

    File -> Invalidate Caches / Restart...
    
    0 讨论(0)
  • 2020-12-06 00:43

    For main activity in your manifest you have to add this with category LAUNCHER (First Activity on launch app):

    <activity
        android:name=".MainActivity"
        android:label="YourAppName"
        android:theme="@style/AppTheme.NoActionBar" >
          <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
    </activity>
    

    For other activity you have to change category to DEFAULT:

    <activity
        android:name=".OtherActivity"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
                <action android:name="package.OtherActivity" />
    
                <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    

    Check this Activity and this Start Another Activity

    So your code is:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mrrobot.mycoolweather" >
    <uses-permission android:name="android.permission.INTERNET"/>
    
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
    
        <activity
            android:name=".activity.ChooseAreaActivity"
            android:label="@string/app_name" >
              <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
              </intent-filter>
        </activity>
    </application>
    
    </manifest>
    
    0 讨论(0)
  • 2020-12-06 00:45

    This happened to me aswell took me ages to figure out why, but a weird bug I spotted is that if you run the app with breakpoints in your code without debugging mode it will cause this error to happen.

    Quick fix for now: Only use breakpoints for degbugging mode.

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