23

I've created a wear app and used the Android Studio template to create it and haven't made any changes other than to drag and drop a button onto the MainActivity of the wear app.

When I try and run the watch app in the Run/Debug Configurations is Launch default Activity is ticked then there is an error message saying: "Error: Default Activity not found".

I've searched for previous posting on this and the answer is messing around with module sources and stuff. Is that really the correct solution in this situation? If so, then why isn't the Android Studio setting everything up correctly in the first place - after all the project was created by an AS template, why isn't the template setting things up correctly?

If its not applicable, then how do I get the watch app to execute and launch its activity when executed directly using Studio?

Studio Version: 1.0.2

Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
  • Were you able to debug the app before you added the button? Also, double check that the name of your `Activity` matches what is specified in the `AndroidManifest` file. Lastly, are you using any 3'd party libraries? Gradle will, by default, combine manifest files. If another `Activity` was specified in one of the library manifest files then this could cause issues. Also try the suggestions in this post: http://stackoverflow.com/questions/24437459/default-activity-not-found-android-studio-0-6-1 – Willis Jan 15 '15 at 18:22
  • Thanks for the comment. I got the same error before adding the button. I haven't included any additional libraries. The activity is called MainActivity which is also the name in the manifest. None of the answers in the link are applicable it seems. – Gruntcakes Jan 15 '15 at 18:28
  • I can make the error go away if I explicitly select the activity as the launch activity rather than selecting to launch the default activity, but was wondering why there's the error and if its indicative of some problem that will cause further issues down the road. – Gruntcakes Jan 15 '15 at 18:37
  • There's a bug report open for this. https://code.google.com/p/android/issues/detail?id=232988&thanks=232988&ts=1485476461 – Erik Jan 27 '17 at 00:22

3 Answers3

59

I also had an issue similar to this after adding a Watchface, and thought I would chime in with what fixed it for me.

In Android Studio 2.2.1: Run -> Edit -> Your App -> watchface -> General -> Launch Options -> Launch: Nothing

By default, mine was selected to run the default activity, which is incorrect for a watch face.

Screenshot of run configuration showing Launch: Nothing

Boken
  • 4,825
  • 10
  • 32
  • 42
Kevin Gray
  • 873
  • 7
  • 15
2

In AndroidManifest.xml file for wear, make sure that there is at least one activity and the activity that you want to launch has the following intent-filters in it:

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

There is another tip mentioned in this answer.

Community
  • 1
  • 1
  • Thanks. Simple answer to such an annoying problem that Google refuses to fix in their samples. – IgorGanapolsky May 02 '16 at 18:22
  • According to https://codelabs.developers.google.com/codelabs/watchface/index.html#0 Kevin Gray's answer is the correct approach, don't do it by modifying the Manifest. – Daniel F Apr 13 '19 at 13:08
1

The sample code for the Watch Face contains the following comment

Important Note: Because watch face apps do not have a default Activity in their project, you will need to set your Configurations to "Do not launch Activity" for both the Wear and/or Application modules. If you are unsure how to do this, please review the "Run Starter project" section in the Google Watch Face Code Lab: https://codelabs.developers.google.com/codelabs/watchface/index.html#0

Daniel F
  • 13,684
  • 11
  • 87
  • 116
  • Thanks Bro. I think this should be marked as answer. Not sure why people didn't vote for this. This is exactly mentioned it in Readme file. – arango_86 Sep 26 '22 at 13:21