androidandroid-studioandroid-activityusb-debugging

Android Studio: Default Activity Not Found and than USB Debugging not woking


I re-installed my Android Studio. My first problem was, that when I try to run my Activity, I got an error:

Default Activity Not Found

. So I change the configuration, instead of choosing Default Activity in the Launch Option I choose Nothing.

I think this is the problem why nothing is happening after I run the project. It's make sense, cuz nothing is lauch or am I wrong?

The Android Studio see my device and it's connecting via USB. I done this before, so I know that I have to allow USB Debugging on my device and i did. After I hit run, start to loading, and than it's says that:

Install succesfully finished in 212 ms. App restart succedful without requiring a re-install.

But nothing is happening neither in my computer or my phone.


Solution

  • In order to start your App, it needs an "entry point". You can define it in the AndroidManifest.xml file like:

    <activity android:name="com.myapp.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    

    In the first line you add the package path + your Activity you want to open at startup. The reason why you got the error msg Default Activity not found probably is, that you created a project without an Activity. To create a new Activity simply right-click to the package in Android Studio -> select New -> Activity -> and then e.g. Empty Activity