首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Wear Packaging

Android Wear Packaging
EN

Stack Overflow用户
提问于 2014-11-28 22:48:22
回答 3查看 983关注 0票数 1

我无法打包我的Android Wear应用程序,当它安装在手机上时,它的穿戴版本不在手表上。

这是我的gradle文件(佩戴):

代码语言:javascript
复制
buildscript {
dependencies {

    }
}

apply plugin: 'com.android.application'

def versionMajor = Integer.parseInt(APP_VERSION_MAJOR)
def versionMinor = Integer.parseInt(APP_VERSION_MINOR)
def versionPatch = Integer.parseInt(APP_VERSION_PATCH)
def versionBuild = Integer.parseInt(APP_VERSION_BUILD)

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
    applicationId project.PACKAGE_NAME
    minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION_WEAR)
    targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
    versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
    versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
    manifestPlaceholders = [watchfaceName: project.WATCHFACE_NAME, appName: project.APP_NAME]       
}

signingConfigs {
    release {
        storeFile file("/Users/jimmy/Developer/keystore")
        keyAlias 'name'
        storePassword 'pw'
        keyPassword 'pw'
    }
}

buildTypes {
    release {
        runProguard false
        signingConfig signingConfigs.release
    }
}
}

dependencies {
    compile project(':submodules:watchface-gears:library')
    compile project(':commonlibrary')
    compile 'com.google.android.support:wearable:1.+'
    compile 'com.google.android.gms:play-services-wearable:6.+'
    compile 'com.jakewharton:butterknife:5.1.+'
}

和移动端:

代码语言:javascript
复制
apply plugin: 'com.android.application'

def versionMajor = Integer.parseInt(APP_VERSION_MAJOR)
def versionMinor = Integer.parseInt(APP_VERSION_MINOR)
def versionPatch = Integer.parseInt(APP_VERSION_PATCH)
def versionBuild = Integer.parseInt(APP_VERSION_BUILD)

android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        applicationId project.PACKAGE_NAME
        minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
        versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
        versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
        manifestPlaceholders = [watchfaceName: project.WATCHFACE_NAME, appName: project.APP_NAME]

    }

    signingConfigs {
        release {
            storeFile file("/Users/jimmy/Developer/keystore")
            keyAlias 'name'
            storePassword 'pw'
            keyPassword 'pw'
        }
    }

    buildTypes {
        release {
            runProguard false
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile project(':commonlibrary')
    compile "com.android.support:appcompat-v7:21.+"
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
}

还有我的宣言(穿着):

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.jaumard.skullface">

    <uses-feature android:name="android.hardware.type.watch"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND"/>

    <application
            android:label="${appName}"
            android:name="com.jaumard.skullface.WatchfaceApp">
        <activity android:name="android.support.wearable.activity.ConfirmationActivity"
                  android:theme="@style/ConfirmTheme"/>
        <activity
                android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
                android:name="com.jaumard.skullface.activity.WatchfaceActivity"
                android:label="${watchfaceName}"
                android:taskAffinity=""
                android:allowEmbedded="true">

            <meta-data android:name="com.google.android.clockwork.home.preview" android:resource="@drawable/preview"/>

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="com.google.android.clockwork.home.category.HOME_BACKGROUND"/>
            </intent-filter>
        </activity>

        <activity
                android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
                android:name="com.jaumard.skullface.activity.DrawerActivity"
                android:label="${watchfaceName}"
                android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
                android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
                android:name="com.jaumard.skullface.activity.DreamSettingsActivity"
                android:label="${watchfaceName}">

        </activity>
        <service
                android:name=".services.LauncherService"
                android:enabled="true">
        </service>
        <service
                android:name="com.jaumard.skullface.services.DataService">
            <intent-filter>
                <action android:name="com.google.android.gms.wearable.BIND_LISTENER"/>
            </intent-filter>
        </service>
        <service
                android:name="com.jaumard.skullface.services.DreamerService"
                android:exported="true"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.service.dreams.DreamService" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <!-- Point to additional information for this dream (optional) -->
            <meta-data
                    android:name="android.service.dream"
                    android:resource="@xml/dream" />
        </service>
        <receiver android:name="com.jaumard.skullface.helpers.PackageReceiver"
                  android:exported="true"
                  android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REMOVED"/>
                <action android:name="android.intent.action.PACKAGE_ADDED"/>
                <action android:name="android.intent.action.PACKAGE_REPLACED"/>
                <data android:scheme="package"/>
            </intent-filter>
        </receiver>

        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
    </application>

</manifest>

和移动端:

代码语言:javascript
复制
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.jaumard.skullface">

    <uses-feature android:name="android.hardware.type.watch" android:required="false"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND"/>

    <application
            android:allowBackup="true"
            android:icon="@drawable/preview"
            android:theme="@style/AppTheme"
            android:label="${appName}">
        <activity android:name="com.jaumard.skullface.activities.MainActivity"
                  android:label="${appName}"
                  android:icon="@drawable/preview"
                >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name="com.jaumard.skullface.activities.DrawerActivity"
                  android:label="@string/home_drawer">
        </activity>
        <activity android:name="com.jaumard.skullface.activities.ClockActivity"
                  android:label="@string/home_clock">
        </activity>
        <receiver android:name="com.jaumard.skullface.DataListener" android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
                <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
                <action android:name="jaumard.ACTION_BATTERY_CHANGED"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <service
                android:name="com.jaumard.skullface.services.DataService" android:exported="false"
                android:enabled="true">
        </service>
        <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version"/>
    </application>
</manifest>

我不明白为什么不安装穿戴应用程序...

编辑:我可以通过手动签名/打包穿戴应用程序或者像这样修改gradle文件来使其工作:

代码语言:javascript
复制
wearApp project(':wear')
wearApp files('../wear/build/outputs/apk/wear_release.apk')
EN

回答 3

Stack Overflow用户

发布于 2014-12-01 18:17:52

  1. 您是否使用版本密钥进行签名?你必须使用它,调试密钥在这里不起作用。
  2. 检查你的最终apk文件。如果您正确地将穿戴项目包含到移动设备中,那么您的res/raw文件夹

中应该有android_wear_micro_apk.apk

票数 1
EN

Stack Overflow用户

发布于 2014-12-07 02:05:11

我也有同样的问题,但是通过检查权限来解决它。您是否可以检查可穿戴应用程序和移动应用程序是否具有完全相同的权限?

票数 0
EN

Stack Overflow用户

发布于 2015-12-31 12:07:52

如果你使用gradle构建Android Studio,只需将可穿戴应用程序作为手机项目中的一个模块即可。然后,您必须确保已完成以下配置:

  1. 手机清单和可穿戴应用清单应声明完全相同的permissions.
  2. Ensure,即可穿戴应用模块和手持应用模块具有相同的包名和版本号。
  3. 使用调试密钥签名时,不会通过安装手机应用自动安装你的可穿戴应用。您应该通过蓝牙调试在可穿戴设备上手动安装可穿戴应用。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27191116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档