Monday, December 1, 2014

After adding an Android Library Module to a project, Android Studio does not launch the default app activity

I was following the official Android Studio documentation on building an Android project with Gradle but every time I run the app on my device, the activity for the library module kept on appearing no matter what changes I made to the app's default activity. The instruction added a button to the default activity and I was expecting a button to appear but what came out was as shown below.



The documentation did not mention anything about this. And after thinking through the problem, I figured that the Run configuration in the Android Studio needs to be told to run the app's activity. The following steps show how to change the Run Configuration.

  1. In Android Studio, select Edit Configuration.



    The Run/Debug Configuration dialog box appears.

  2. In the Activity group box, toggle on Launch. Then click browse [...].

    The Select Activity Class dialog appears.

  3. Select the desired app's activity e.g. MainActivity. Click OK.


  4. Click OK.
  5. In Android Studio, run the app again.

    This time, the correct activity with the added button appears.

4 comments:

  1. Hola buenas tardes, Buen post, me ayudo a solucionar este problema muchisimas gracias.!!!

    ReplyDelete
  2. Hola buenas tardes, Buen post, me ayudo a solucionar este problema muchisimas gracias.!!!

    ReplyDelete
  3. Thanks for the help. I was stuck on this too.

    ReplyDelete
  4. Thanks for the help. I was stuck on this too.

    ReplyDelete