代码之家  ›  专栏  ›  技术社区  ›  zono

Android Wear:不将我的应用程序同步到Watch。为什么?

  •  0
  • zono  · 技术社区  · 10 年前

    我发布了一款android穿戴应用。我在Google Play上安装了该应用程序,并尝试通过Google Android Wear应用程序与我的Android Wear同步,但没有成功。

    我想我安装的apk不包括“WEAR.apk”。我怎么能包括它?

    当我在Android Studio上生成apk时,生成了两个apk。我只上传了一个apk“APPLICATION.apk”。我希望“APPLICATION.apk“包含“WEAR.apk。

    build.gradle具有WEAR的依赖性。

    wearApp project(':wear')
    

    有人知道任何可能的原因和解决方案吗。

    如有任何帮助,我们将不胜感激。

    谢谢

    [更新1]

    应用程序模块

    AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.hogehoge.bip" >
    
        <uses-feature android:name="android.hardware.camera" android:required="false" />
        <uses-feature android:name="android.hardware.camera.autofocus" />
    
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.INTERNET" />.
    
        <application
                android:allowBackup="true"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    
            <meta-data
                    android:name="com.google.android.gms.version"
                    android:value="@integer/google_play_services_version" />
    
            <activity
                    android:name="com.hogehoge.bip.MainActivity"
                    android:label="@string/app_name"
                    android:screenOrientation="landscape"
                    android:launchMode="singleTask" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    </manifest>
    

    建筑物玻璃

    apply plugin: 'android'
    
    android {
        compileSdkVersion 18
        buildToolsVersion '20'
    
        defaultConfig {
            minSdkVersion 19
            targetSdkVersion 19
            versionCode 2
            versionName "0.1"
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.google.android.gms:play-services:5.0.+@aar'
        compile 'com.android.support:support-v4:20.0.+'
        wearApp project(':Wearable')
        compile files('libs/core-2.2.jar')
        compile files('libs/javase-2.2.jar')
        compile files('libs/android-async-http-1.4.5.jar')
    }
    

    可穿戴模块

    AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.hogehoge.bip" >
    
        <uses-feature android:name="android.hardware.type.watch" />
    
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.VIBRATE" />
    
        <application
                android:allowBackup="true"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.DeviceDefault">
    
            <meta-data
                    android:name="com.google.android.gms.version"
                    android:value="@integer/google_play_services_version" />
    
            <service
                    android:name="com.hogehoge.bip.DataLayerListenerService" >
                <intent-filter>
                    <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
                </intent-filter>
            </service>
    
            <activity
                android:name="com.hogehoge.bip.PagerActivity"
                android:screenOrientation="portrait"
                android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
        </application>
    </manifest>
    

    建筑物玻璃

    apply plugin: 'android'
    
    android {
        compileSdkVersion 20
        buildToolsVersion '20'
    
        defaultConfig {
            minSdkVersion 20
            targetSdkVersion 20
            versionCode 2
            versionName "0.1"
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.google.android.gms:play-services-wearable:+'
        compile files('libs/internal_impl-20.0.0.jar')
        compile files('libs/classes.jar')
    }
    

    [更新2]

    我的应用程序是免费的。未付费应用程序。

    我生成了以下apk:;Application release.apk(3M)和Wearable release.apk(1.1M)。

    [更新3]

    我注意到类似的问题已经发布。

    Android Wear generate two apk

    根据帖子,我可能不得不使用“释放键”。我正在检查。

    [更新4]

    我解压缩了我发布的Google Play的apk。结果,我在handledapp.apk中发现了可穿戴的.apk。

    我不知道下一步该做什么。你能帮助我吗!

    [已解决更新5]

    我听从了@Gabriele Mariotti的建议。那就行了!

    检查您的权限。智能手机部分需要 Wear组件具有的权限。

    对两个应用程序(穿戴和移动)使用相同的软件包id

    Android Wear App not installed

    1 回复  |  直到 8 年前
        1
  •  2
  •   SoftwareDev    10 年前

    如果这是一个付费应用,你不能使用

    wearApp project(':wear')
    

    你必须 do it manually

    如果它不是付费应用程序(如果它是免费的),“APPLICATION.apk”的文件大小是否符合您的预期?(即wear.apk+mobile.apk)

    同时发布清单和build.gradle文件。