Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Default activity not found" for a wearable app created with Android Studio template

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

like image 631
Gruntcakes Avatar asked Jan 15 '15 18:01

Gruntcakes


3 Answers

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

like image 89
Kevin Gray Avatar answered Nov 20 '22 00:11

Kevin Gray


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.

like image 42
sahilkhosla Avatar answered Nov 19 '22 23:11

sahilkhosla


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

like image 1
Daniel F Avatar answered Nov 20 '22 00:11

Daniel F