I need to distribute my wear application along with the mobile application. Therefore the apk of the application of the wear will be embedded along with that of the main application and will be installed automatically in device wear synchronized.
When installing the application on the mobile phone, the wear application does not appear in the list of available applications.
Through adb I have examined the messages of the device log android wear.
The installation of the application if done as you can see in the following log:
03-20 19:22:41.115 3217-4606/? I/PkgMgrInstallUtil: Sending install intent to PackageInstaller Intent { act=android.intent.action.INSTALL_PACKAGE dat=content://com.google.android.clockwork.home.provider/host/es.company.myapp/wearable/es.company.myapp/apk typ=vnd.android.cursor.item/wearable_apk cmp=com.google.android.packageinstaller/com.android.packageinstaller.wear.WearPackageInstallerService (has extras) } for es.company.myapp
03-20 19:22:41.510 4256-4610/? W/PackageParser: Unknown element under <manifest>: meta-data at /data/user/0/com.google.android.packageinstaller/files/tmp/es.company.myapp.apk Binary XML file line #25
03-20 19:22:41.705 4256-4610/? I/WearPkgInstallerService: Sent installation request for es.company.myapp
03-20 19:22:41.730 4010-4021/? D/DefContainer: Copying /data/user/0/com.google.android.packageinstaller/files/tmp/es.company.myapp.apk to base.apk
03-20 19:22:42.967 3026-3049/? I/PackageManager.DexOptimizer: Running de
xopt (dex2oat) on: /data/app/vmdl413702780.tmp/base.apk pkg=es.company.myapp isa=arm vmSafeMode=false debuggable=false oatDir = /data/app/vmdl413702780.tmp/oat bootComplete=true
03-20 19:23:11.998 4256-4269/? I/WearPkgInstallerService: Package es.company.myapp was installed.
03-20 19:23:12.652 3692-4622/? I/Finsky: [125] com.google.android.finsky.services.WearablePackageService.onHandleIntent: Updating package info (es.company.myapp)
03-20 19:23:18.588 3026-4029/? I/ActivityManager: START u0 {act=com.google.android.clockwork.packagemanager.ACTION_LAUNCH_ACTIVITY dat=package:es.company.myapp cmp=com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity} from uid 10003 on display 0
A notification appears in the main wall that gives access to the application and as you can see in the following log I get access to the MainActivity
03-20 19:23:18.589 3026-4029/? W/ActivityManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=com.google.android.clockwork.packagemanager.ACTION_LAUNCH_ACTIVITY dat=package:es.company.myapp cmp=com.google.android.wearable.app/com.google.android.clockwork.home.HomeActivity }
03-20 19:23:18.730 3026-3036/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=es.company.myapp cmp=es.company.myapp/.SplashScreenActivity} from uid 10003 on display 0
03-20 19:23:18.897 3026-3037/? I/ActivityManager: Start proc 4637:es.company.myapp/u0a34 for activity es.company.myapp/.SplashScreenActivity
03-20 19:23:19.066 4637-4637/? W/System: ClassLoader referenced unknown path: /data/app/es.company.myapp-1/lib/arm
03-20 19:23:19.960 3026-3044/? I/ActivityManager: Displayed es.company.myapp/.SplashScreenActivity: +1s115ms
03-20 19:23:21.667 3026-4277/? I/ActivityManager: START u0 {flg=0x20000 cmp=es.company.myapp/.MainActivity} from uid 10034 on display 0
03-20 19:23:22.591 3026-3044/? I/ActivityManager: Displayed es.company.myapp/.MainActivity: +913ms
The problem is that after a while the application is stopped by the system and automatically uninstalled as you can see in the following log.
03-20 19:24:00.118 3026-3039/? I/ActivityManager: Force stopping es.company.myapp appid=10034 user=-1: uninstall pkg
03-20 19:24:00.118 3026-3039/? I/ActivityManager: Killing 4637:es.company.myapp/u0a34 (adj 0): stop es.company.myapp
03-20 19:24:00.221 3026-4028/? I/WindowState: WIN DEATH: Window{d2fe108 u0 es.usal.bisite.ebikemotion/es.company.myapp.MainActivity}
03-20 19:24:00.344 3026-3039/? W/ActivityManager: Scheduling restart of crashed service es.company.myapp/.DisconnectListenerService in 1000ms
03-20 19:24:00.345 3026-3039/? W/ActivityManager: Force removing ActivityRecord{98383f0 u0 es.company.myapp/.MainActivity t9}: app died, no saved state
03-20 19:24:00.436 3026-3039/? I/ActivityManager: Force stopping service ServiceRecord{53da3f9 u0 es.company.myapp/.DisconnectListenerService}
03-20 19:24:00.451 3026-3267/? W/ActivityManager: Spurious death for ProcessRecord{60506cb 0:es.company.myapp/u0a34}, curProc for 4637: null
03-20 19:24:00.957 3026-3049/? W/PackageManager: Couldn't remove dex file for package: at location /data/app/es.company.myapp-1/base.apk, retcode=-1
03-20 19:24:00.965 3692-3692/? I/Finsky: [1] com.google.android.finsky.services.PackageJobService$2.uninstallSucceeded: Uninstall succeed for es.company.myapp (request 36457867-1521570082816)
I have tried to synchronize all the applications of the phone, but it is not installed. I've also resynchronized the wear with the phone.
Next I expose the manifest of the application wear. I have reviewed the documentation and it is not necessary to specify anything else
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.company.myapp">
<uses-feature android:name="android.hardware.type.watch" android:required="true"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".ApplicationWear"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-library
android:name="com.google.android.wearable" android:required="false" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="apikey"/>
<activity android:name=".SplashScreenActivity" android:theme="@android:style/Theme.DeviceDefault.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault.Light"/>
<activity android:name=".MapActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault.Light"/>
<service android:name=".DisconnectListenerService"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="apikey" />
</application>
</manifest>
Next I will include the gradle file of the app:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "es.company.myapp"
minSdkVersion 18
targetSdkVersion 25
versionCode 357
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:support-v4:${rootProject.support_library_version}"
implementation "com.android.support:percent:${rootProject.support_library_version}"
implementation "com.google.android.gms:play-services-wearable:${rootProject.play_services_version}"
implementation "com.google.android.gms:play-services-maps:${rootProject.play_services_version}"
implementation 'com.google.android.support:wearable:2.0.1'
compileOnly 'com.google.android.wearable:wearable:2.0.1'
implementation 'com.patloew.rxwear:rxwear:1.3.0'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
//GLIDE
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'jp.wasabeef:glide-transformations:2.0.1'
//ButterKnife
implementation "com.jakewharton:butterknife:${rootProject.butterknife}"
annotationProcessor "com.jakewharton:butterknife-compiler:${rootProject.butterknife}"
implementation "io.reactivex:rxjava:${rootProject.rx_java}"
implementation "io.reactivex:rxandroid:${rootProject.rx_android}"
//TIMBER
implementation "com.jakewharton.timber:timber:${rootProject.timber}"
implementation('com.crashlytics.sdk.android:answers:1.3.12@aar') {
transitive = true;
}
implementation('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
transitive = true;
}
}
Library Versions:
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '26.0.2'
support_library_version = "27.0.2"
play_services_version = "11.0.2"
Can someone tell me how I can solve the problem?
Thank you!!