title: Android Wear app not installing through handset
body: <p>I'm trying to get a wearable app installed through an Android handset using the 'Package with Android Studio method' found <a href="http://developer.android.com/training/wearables/apps/packaging.html" rel="noreferrer">here</a> but it's not working. The apk is never installed to the wearable device. This is the logcat output:</p>
  
  <pre><code>07-28 15:11:54.107      766-820/? W/PackageManager﹕ Unknown permission com.google.android.wearable.READ_SETTINGS in package com.google.android.gms
  07-28 15:11:54.117      766-820/? W/PackageManager﹕ Not granting permission com.google.android.gm.permission.AUTO_SEND to package com.google.android.wearable.app (protectionLevel=2 flags=0x88be44)
  07-28 15:11:54.117      766-820/? W/PackageManager﹕ Not granting permission android.permission.MEDIA_CONTENT_CONTROL to package com.google.android.wearable.app (protectionLevel=18 flags=0x88be44)
  07-28 15:11:55.047      632-632/? D/WearablePkgInstaller﹕ Got PackageUpdateReceiver message Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:my.package.name flg=0x4000010 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.packagemanager.PackageUpdateReceiver (has extras) }
  07-28 15:11:55.177      632-632/? D/WearablePkgInstaller﹕ Got PackageUpdateReceiver message Intent { act=android.intent.action.PACKAGE_ADDED dat=package:my.package.name flg=0x4000010 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.packagemanager.PackageUpdateReceiver (has extras) }
  </code></pre>
  
  <p>As a side note I am able to package manually (also described in the link above) and the apk gets installed on the wearable device when I run it on the handset. I am using buildToolsVersion 20.0.0, I'm running Android Studio 0.8.2 and have this line in my handset module's build.gradle:</p>
  
  <pre><code>wearApp project(':wearable')
  </code></pre>
  
  <p>I've run out of ideas on how to debug this, the logs seem pretty useless. Any ideas?</p>
  
  <p>EDIT: Going to post relevant sections of Manifest and build.gradle for both the handset and wearable module. </p>
  
  <p><strong>Handset Manifest</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="my.package.name"
            android:installLocation="auto"
            android:versionCode="259"
            android:versionName="4.6.1"&gt;
  
      &lt;!-- =========== --&gt;
      &lt;!-- PERMISSIONS --&gt;
      &lt;!-- =========== --&gt;
  
      &lt;permission
          android:name="my.app.name.permission.C2D_MESSAGE"
          android:protectionLevel="signature"/&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
  
      &lt;!-- ====================== --&gt;
      &lt;!-- APPLICATION PROPERTIES --&gt;
      &lt;!-- ====================== --&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="9"
          android:targetSdkVersion="19" /&gt;
  
      &lt;supports-screens
          android:anyDensity="true"
          android:largeScreens="true"
          android:normalScreens="true"
          android:smallScreens="true"
          android:xlargeScreens="true"/&gt;
  
      &lt;application
          android:name=".AppState"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/Theme.MyApp"
          android:hardwareAccelerated="true"&gt;
  
  
          &lt;!-- ==================== --&gt;
          &lt;!-- GOOGLE PLAY SERVICES --&gt;
          &lt;!-- ==================== --&gt;
  
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version"/&gt;
  
          &lt;!-- ================== --&gt;
          &lt;!-- Android Wear --&gt;
          &lt;!-- ================== --&gt;
  
          &lt;service
              android:name=".wear.DataLayerListenerService" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.android.gms.wearable.BIND_LISTENER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  
          &lt;!-- This is used for manual packaging I have this commented out when --&gt;
          &lt;!-- packaging with Android Studio--&gt;
          &lt;!--&lt;meta-data android:name="com.google.android.wearable.beta.app"--&gt;
                  &lt;!--android:resource="@xml/wearable_app_desc"/&gt;--&gt;
  
          ...The rest of the activities
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>Handset build.gradle</strong></p>
  
  <pre><code>buildscript {
      repositories {
          maven { url 'http://download.crashlytics.com/maven' }
      }
  
      dependencies {
      }
  }
  
  apply plugin: 'com.android.application'
  apply plugin: 'crashlytics'
  apply plugin: 'newrelic'
  
  repositories {
      mavenCentral()
      maven { url 'http://download.crashlytics.com/maven' }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: '*.jar')
      compile 'com.android.support:support-v4:20.0.+'
      compile 'com.android.support:appcompat-v7:20.0.+'
      compile project(':facebook')
      compile project(':mopub-sdk')
      compile project(':GooglePlay')
      compile 'com.newrelic.agent.android:android-agent:3.+'
      compile 'com.crashlytics.android:crashlytics:1.+'
      androidTestCompile fileTree(dir: 'tests/libs', include: '*.jar')
      wearApp project(':wearable')
  }
  
  android {
      compileSdkVersion 19
      buildToolsVersion '20.0.0'
  
      //Build type is debug to avoid conflict with Proguard
      testBuildType = "debug"
  
      defaultConfig {
          testApplicationId "my.package.name.test"
          testInstrumentationRunner "com.zutubi.android.junitreport.JUnitReportTestRunner"
      }
  
      lintOptions {
          // We do not want to abort the build due to lint errors
          abortOnError false
      }
  
      sourceSets {
          // Main is the default unless stated otherwise
          main {
              manifest.srcFile 'AndroidManifest.xml'
              java.srcDirs = ['src']
              resources.srcDirs = ['src']
              aidl.srcDirs = ['src']
              renderscript.srcDirs = ['src']
              res.srcDirs = ['res']
              assets.srcDirs = ['assets']
          }
          // Testing
          androidTest.setRoot('tests')
          androidTest {
              java.srcDirs = ['tests/src']
              res.srcDirs = ['tests/res']
          }
          // Cannot add beta icons in here because custom flavour source sets are created
          // during compilation and name duplication will result in a crash
      }
  
      signingConfigs {
          debug {
              storeFile file("**")
              storePassword "***"
              keyAlias "***"
              keyPassword "***"
          }
          release {
              storeFile file("***")
              storePassword "***"
              keyAlias "***"
              keyPassword "***"
          }
      }
  
      buildTypes {
          // Development configuration
          debug {
              debuggable true
              jniDebugBuild true
              signingConfig signingConfigs.debug
              runProguard false
          }
  
          // Release configuration
          release {
              debuggable false
              jniDebugBuild false
              signingConfig signingConfigs.release
  
                // COMMENTED PROGUARD OUT FOR NOW TO SEE IF IT WILL HELP
  //            // Configure ProGuard
  //            runProguard true
  //            // General configuration
  //            proguardFile 'proguard/proguard.cfg'
  //            // Add all of our component-specific configurations (excluding the Android generic, as we want it to be last)
  //            FileTree tree =  fileTree(dir: 'proguard', include: '*.txt', exclude: 'Android.txt')
  //            tree.each {File file -&gt;
  //                proguardFile file.getCanonicalPath()
  //            }
  //            // Add a fallback configuration for all Android apps
  //            proguardFile 'proguard/Android.txt'
          }
  
          // Release configuration, but debuggable and without ProGuard
          // Used for testing features like G+ and in-app billing where a release config is required
          staging {
              debuggable true
              jniDebugBuild true
              signingConfig signingConfigs.release
              runProguard false
          }
      }
  
      productFlavors {
          production {
              applicationId "my.package.name"
          }
          internalBeta {
              applicationId "my.internalbetapackage.name"
              // Beta icons
              sourceSets.internalBeta.res.srcDirs = ['res-beta/internal']
          }
          externalBeta {
              applicationId "my.externalbetapackage.name"
              // Beta icons
              sourceSets.externalBeta.res.srcDirs = ['res-beta/external']
          }
          testing{
              applicationId "my.package.name"
          }
      }
  
      // Without this, gradle will complain that duplicate files were added to the APK, see:
      // http://stackoverflow.com/questions/20673888/duplicate-files-copied-android-studio-0-4-0
      packagingOptions {
          exclude 'META-INF/LICENSE.txt' // twitter4j
          exclude 'META-INF/ASL2.0'      // jackson
          exclude 'META-INF/LICENSE'     // jackson
          exclude 'META-INF/NOTICE'      // jackson
      }
  
  }
  
  task makeTestApks {
      dependsOn "assembleProductionRelease"
      dependsOn "assembleProductionTest"
  }
  </code></pre>
  
  <p><strong>Wearable Manifest</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="my.package.name"&gt;
  
      &lt;uses-feature android:name="android.hardware.type.watch" android:required="false"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.DeviceDefault" &gt;
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
  
          &lt;activity
              android:name=".WearReaderActivity"
              android:label="MyApp" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
  
              &lt;intent-filter&gt;
                  &lt;action android:name="my.package.name.READ"/&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;service
              android:name=".wear.DataLayerListenerService" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.android.gms.wearable.BIND_LISTENER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>Wearable build.gradle</strong></p>
  
  <pre><code>repositories {
      mavenCentral()
  }
  
  apply plugin: 'com.android.application'
  apply plugin: 'newrelic'
  
  android {
      compileSdkVersion 19
      buildToolsVersion '20.0.0'
      defaultConfig {
          minSdkVersion 19
          targetSdkVersion 19
          versionCode 259
          versionName "4.6.1"
      }
  
      signingConfigs {
          debug {
              keyAlias '***'
              keyPassword '***'
              storeFile file('sameAsHandset/debug.keystore')
              storePassword '***'
          }
          release {
              storeFile file("sameAsHandset/android.keystore")
              storePassword "***"
              keyAlias "***"
              keyPassword "***"
          }
      }
  
      buildTypes {
          release {
              debuggable true
              jniDebugBuild false
              signingConfig signingConfigs.release
          }
      }
  
      productFlavors {
          production {
              applicationId "my.package.name"
          }
          internalBeta {
              applicationId "my.internalBetaPackage.name"
              // Beta icons
              sourceSets.internalBeta.res.srcDirs = ['res-beta/internal']
          }
          externalBeta {
              applicationId "my.externalBetaPackage.name"
              // Beta icons
              sourceSets.externalBeta.res.srcDirs = ['res-beta/external']
          }
          testing{
              applicationId "my.package.name"
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile project(':GooglePlay')
      compile 'com.newrelic.agent.android:android-agent:3.+'
  }
  </code></pre>