Android 安卓耐磨包装

Android 安卓耐磨包装,android,release,packaging,wear-os,Android,Release,Packaging,Wear Os,我无法打包我的Android Wear应用程序,当它安装在手机上时,Wear版本不在手表上 这是我的gradle文件(磨损): 及流动电话: apply plugin: 'com.android.application' def versionMajor = Integer.parseInt(APP_VERSION_MAJOR) def versionMinor = Integer.parseInt(APP_VERSION_MINOR) def versionPatch = Integer.p

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

这是我的gradle文件(磨损):

及流动电话:

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 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>
还有我的舱单(佩戴):

  • 您是否使用释放密钥进行签名?你必须使用它,调试键在这里不起作用

  • 检查您的最终apk文件。如果您正确地将wear项目包括到手机中,那么您的res/raw文件夹中应该有android_wear_micro_apk.apk


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

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

  • 电话清单和可穿戴清单应声明完全相同的权限

  • 确保可穿戴和手持应用程序模块具有相同的软件包名称和版本号

  • 使用调试密钥签名时,安装手机应用程序不会自动安装您的可穿戴应用程序。您应该通过蓝牙调试在可穿戴设备上手动安装可穿戴应用程序


  • 如何使用gradle启动构建?WearApp仅在已签署的发布版本上加入手持应用。是的,我使用发布版本启动它。当我手动打包wear应用程序时,或者当我使用:wearApp项目(“:wear”)wearApp文件(“../wear/build/outputs/apk/wear_release.apk”)修改我的gradle文件时,它会起作用。通常,在手机上启动移动应用程序后,安装wear应用程序需要多长时间,假设手机和佩带是连接的?1。是的,我使用释放键2。是的,我在你的res/raw中有android_wear_micro_apk.apk,但在手机上安装时不同步。我让它工作(见我的编辑)但这不是官方的方式,你能试着像以前一样打包应用程序吗?如果你能在你的res/raw文件夹中看到android_wear_micro_apk.apk,然后在android wear应用程序中按Resync apps吗?你会使用android Studio来构建发布版本吗?我尝试了android Studio和IntelliJ,但我更喜欢IntelliJ,所以请尝试几次在Android studio“完全相同的权限”上,我认为可穿戴权限应该是手机权限的子集。
    <?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>
    
    wearApp project(':wear')
    wearApp files('../wear/build/outputs/apk/wear_release.apk')