Packaging wearable apps

て烟熏妆下的殇ゞ 提交于 2019-12-10 17:26:59

问题


I'm in the last stage of developing a watchface service for the android wear devices. The problem is the following: Every time i try to sign my app, two files are being generated: wear-release.apk and mobile-release.apk , there is no other apk. Shouldnt the apk name be my Packagename of the projectdirectory? -Because i tried opening both files with my compatible Smartphone (with a weardevice attached), which always ends instantly in a phrasing error.

Thinngs i have noticed:

  • There is no content in the mobile version package in Android Studio
  • The permissions are only mentioned in the mobile Manifest (also tried with the permissions being on both manifests)
  • it's a normal werable watchface with no config activity
  • Ihe mobile-release apk is way lager than the wear-apk although i have nearly nothing placed in the mobile part. (--> good ,maybe wear-apk is already in the mobile-apk)?
  • I tried to install the apks from the SD card and the phone memory
  • i have install apks from unknown sources turned on.

Thanks for your help & time -Botti560


回答1:


After clicking "Generate Signed APK" Make sure module "mobile" is selected from the drop down. The generated APK containing both wear and mobile modules will be named "mobile-release.apk". Also settings.gradle should have include ':mobile', ':wear' present and also build.gradle (Module: mobile) should have

dependencies {
    wearApp project(':wear')
}

EDIT more content / clarification added below

OK with this edit hopefully I can help you solve your issues!

First off, make sure you are running the latest stable version of Android Studio. As of today's date the latest version is Android Studio 1.1.0 I previously had some issues generating a signed APK on an earlier version. Second make sure you have have the latest SDK files including the latest API (API 22).

Once you have this setup, if generating a singed APK for your app still does not work. I would try making a new android project. Set Minimum SDK for phone to API 18 (4.3 Jelly Bean, the lowest API level compatible with Android Wear). And set the Minimum Wear SDK to API 20 (Android 4.4 KitKat Wear).

Then try to generate a signed APK of this new project without making any changes to it. THIS SHOULD WORK! If you are still having issues, then something is seriously fouled up and I would just reinstall Android studio from scratch.

If this new project does indeed work, then take note of any differences between the manifest and gradle files of this working project and your other, non working one. Any discrepancies you find might very well be your issue.

Finally three files: build.gradle (Project: anAppImade), build.gradle (Moduble: mobile), and build.gradle (Module: wear) should look something like this (respectively)

build.gradle (Project: anAppImade)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle (Moduble: mobile)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.ppltalkin.anappimade"
        minSdkVersion 18
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:6.5.87'
}

build.gradle (Module: wear)

apply plugin: 'com.android.application'


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.ppltalkin.anappimade"
        minSdkVersion 20
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.1.0'
    compile 'com.google.android.gms:play-services-wearable:6.5.87'
}



回答2:


Assuming you use android studio:

Your mobile build.gradle file should have the following dependency:

dependencies {
   ...
   wearApp project(':wear')
}

Go to Build > Generate signed apk. In the first window, select mobile as your module.

Now when the build is complete, the wear module will automatically be embedded into the mobile module. The mobile apk is the one you distribute. Wear can be used for testing.

view this documentation for more detailed instructions.



来源:https://stackoverflow.com/questions/29034165/packaging-wearable-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!