我需要将我的磨损应用程序与移动应用程序一起分发。因此,磨损应用程序的apk将与主应用程序一起嵌入,并将自动安装在设备磨损同步中。
在手机上安装应用程序时,磨损应用程序不会出现在可用应用程序列表中。
通过adb,我已经检查了设备日志android的消息。
如果按照以下日志中的说明完成应用程序的安装:
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
主墙中会显示一条通知,可以访问该应用程序,您可以在以下日志中看到我可以访问 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
问题是,一段时间后,系统会停止应用程序并自动卸载,如下面的日志中所示。
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)
我尝试同步手机的所有应用程序,但未安装。我也用手机重新同步了这件衣服。
接下来,我公开应用程序的清单。我查看了文档,没有必要指定其他内容
<?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>
接下来,我将包含应用程序的gradle文件:
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;
}
}
库版本:
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '26.0.2'
support_library_version = "27.0.2"
play_services_version = "11.0.2"
有人可以告诉我如何解决问题吗?
谢谢!