【发布时间】:2014-11-28 14:48:22
【问题描述】:
我无法打包我的 Android Wear 应用,当它安装在手机上时,手表上没有穿戴版本。
还有我的gradle文件(穿):
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.+'
}
和移动:
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')
}
还有我的Manifest(穿):
<?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>
和移动:
<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 文件来使其工作:
wearApp project(':wear')
wearApp files('../wear/build/outputs/apk/wear_release.apk')
【问题讨论】:
-
如何使用 gradle 启动构建? WearApp 仅在签名版本中加入到手持应用程序中。
-
是的,我使用发行版启动它。当我手动打包磨损应用程序或使用以下命令修改我的 gradle 文件时,它正在工作: wearApp project(':wear') wearApp files('../wear/build/outputs/apk/wear_release.apk')
-
在手机和穿戴设备连接的情况下,一般在手机上启动移动应用后需要多长时间才能安装穿戴应用?
标签: android release packaging wear-os