0

When I am building a new project from scratch with Android Studio 2.2, a mobile and a wear part are being built. As I want to set up a watch face, the following class is built:
public class MyWatchFace extends CanvasWatchFaceService.

Thereafter in my configurations and when I want to run the wear part in an emulator, I get the message: Error running wear: Default Activity not found.

The wear activity has a red X in the select run/debug configuration window. This also happens after upgrading a perfectly working wear-project from Studio 2.1 to 2.2.

I suspect some problem with starting the watch face service, as building the project with an "always on-app" works perfectly. There can't be faults in the manifest, as the fault shows up immediately after creating it, even before anything is being run. And it is definitely not the missing activity, as it just has been built by the system.

Invalidating cache and restart did not help. Everything is ok after re-importing to Studio 2.1. So what has to be changed in 2.2 to get it running?

abielita
  • 13,147
  • 2
  • 17
  • 59
tomseitz
  • 503
  • 2
  • 4
  • 14
  • Make sure that you have atleast one Activity in your project. – Gurjit Singh Oct 04 '16 at 13:10
  • As I am building a CanvasWatchFaceService, there is no activity. Setting the launch option to "nothing" helps somehaow, but still doesnt start... – tomseitz Oct 04 '16 at 20:56
  • However after the third install/deinstall including the emulators it now works; this could be a bug in Studio 2.2, as the launch option is set to activity when creating a watchface; there might be some other mis-configurations as well, when not everything is a fresh install. – tomseitz Oct 04 '16 at 21:46

3 Answers3

0

You may try restarting the Studio, then go to Tools -> Android -> Sync Project with Gradle Files.

This thread might also help.

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>

Also based from this forum, the problem might not with the intent filter, but with activities that were deleted and still in the Manifest. Try to delete those activities in the manifest.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • Thanks for the input. However, as explained above, I do NOT want an activity. Just the watchface running (as a service). Also as stated above the problem could be solved by setting the launch activity to "nothing". The rest of your answer could be the reason, why it finally worked after several reinstalls. So thank you, but unfortunately only half..;-) – tomseitz Oct 05 '16 at 16:36
0

I got the Default Activity not found warning so following advice elsewhere changed the Launch Options to Nothing. Which stopped the problem, but when I tried running nothing happened. Digging a little deeper I realised that nothing at all was being installed on the emulator.

However, in the edit run configuration there is an Installation Options area. As soon as I selected Deploy | Default APK | and retried running it worked fine (I could choose my watch face in the usual way).

James
  • 1,985
  • 18
  • 19
0

You don't need to change anything in the manifest or any where else after creating a new wearable project.

After creating a new project just Follow Bellow Steps:

  1. Choose Edit Configurations

enter image description here

  1. select wear from left side panel
  2. in "Launch Option" select Nothing

enter image description here

When running in emulator, make sure you created wearable emulator and while running you choose wear in Run Configuration.

Shekh Shagar
  • 1,305
  • 1
  • 11
  • 22