pbreault / adb-idea

A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.
Apache License 2.0
2.1k stars 256 forks source link

Choose Main/Launcher activity based on merged manifest #80

Closed degill closed 6 years ago

degill commented 6 years ago

Hi there,

In my projects I usually have different launcher/main activities based on product flavors and/or build types (e.g. DebugActivity, which usually just inherits from my main activity to add toolbar/menu items) and that activity is in a separate source set with its own AndroidManifest entry. As part of that manifest entry I tend to remove the initial launcher/main acitivty so that it does not interfere with the start process or anything else.

ADB IDEA does not honor these merged manifests. Commands like start/restart do not work anymore:

------------- could not bet started on Pixel_2_API_26 [emulator-5554]. 

ADB Output: Starting: Intent { cmp=-------------/.activities.MainActivity }
Error type 3
Error: Activity class {-------------/-------------.activities.MainActivity} does not exist.

The AndroidManifest.xml in debug/AndroidManifest.xml instead of main/AndroidManifest.xml:

        <activity
            android:name=".activities.MainActivity"
            tools:node="remove" />

        <activity
            android:name=".activities.DevelopMainActivity"
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

As you can see, the initial launcher activity will be removed and another one used instead.

pbreault commented 6 years ago

That should be fixed in 1.5.0, can you confirm if it's the case?

degill commented 6 years ago

I can confirm that it is. Thank you Sir. :-)

pbreault commented 6 years ago

Excellent, thank you for reporting it!