1

I have two modules in my android studio project. One module displays "Hello World" on screen, and the other module displays "Hello Module" on screen. How to decide, which module to run when the app launches. Apparently "Hello Module" is getting displayed on screen. How to use the other module by default on launch of the app.

4 Answers4

2

Before the apk is generated, all the manifests in your project are combined in a process called as manifest-merging. So you should be able to change launcher activity by moving the following intent-filter from your old launcher activity to the new launcher activity:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Veneet Reddy
  • 2,707
  • 1
  • 24
  • 40
1

Since Veneet Reddy has given the correct idea about your problem, I'm about to give you this solution in the manifest file do it like this :

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

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

This is the way to do this. However the Manifest file will be seen in the android studio in your left window pane and do remember to choose the Android option from above the menu See the image you'll get a better idea.

Android Manifest File Picture

Happy Learning!

Alok
  • 8,452
  • 13
  • 55
  • 93
0

Every module has a build.gradle file inside. The module which has apply plugin: 'com.android.application' in it's corresponding build.gradle file is supposed to be the base module of the application.

A module can have more than one activity. The AndroidManifest.xml file inside the base module should have it's activities in there. The activity we need to run on app starting has to contain the following codes inside the opening and closing tags of the activity.

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

Got this error trying to add Jetpack Compose to my existing project.

After following the official doc steps, in my case, it was an error in another module I am using in my project; there were no errors in app module.

Android Studio error was completely misleading (like many other times). The best thing to do in these situations is to run gradle in the terminal:

./gradlew assembleDebug

This gave me a specific and error log that I could finally fix. Hope it helps someone else.

moyo
  • 1,312
  • 1
  • 13
  • 29