我无法打包我的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')
}还有我的宣言(穿着):
<?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')发布于 2014-12-01 18:17:52
中应该有android_wear_micro_apk.apk
发布于 2014-12-07 02:05:11
我也有同样的问题,但是通过检查权限来解决它。您是否可以检查可穿戴应用程序和移动应用程序是否具有完全相同的权限?
发布于 2015-12-31 12:07:52
如果你使用gradle构建Android Studio,只需将可穿戴应用程序作为手机项目中的一个模块即可。然后,您必须确保已完成以下配置:
https://stackoverflow.com/questions/27191116
复制相似问题