我开发了SmartWatch的应用程序,其中包含Wear OS 1.5及更高版本。在分发应用程序时,我将它与主应用程序一起包含在同一个apk中。
我编译了一个发行版本并安装了它,在通过调试控制台同步应用程序与SmartWatch时,我收到以下错误消息。
05-03 18:06:55.637 665-1884/? I/PkgMgrInstallUtil: Sending install intent to PackageInstaller Intent { act=android.intent.action.INSTALL_PACKAGE dat=content://com.google.android.clockwork.home.provider/host/com.sergio.application/wearable/com.sergio.application/apk typ=vnd.android.cursor.item/wearable_apk cmp=com.google.android.packageinstaller/com.android.packageinstaller.wear.WearPackageInstallerService (has extras) } for com.sergio.application
05-03 18:06:56.269 1701-1890/? I/WearPkgInstallerService: Sent installation request for es.usal.bisite.ebikemotion
05-03 18:06:56.281 1722-1732/? D/DefContainer: Copying /data/user/0/com.google.android.packageinstaller/files/tmp/com.sergio.application.apk to base.apk
05-03 18:06:56.528 1701-1743/? E/WearPkgInstallerService: Package install failed com.sergio.application, returnCode -103
05-03 18:06:56.528 1701-1743/? I/WearablePkgInstaller: Sending removeFromPermStore to ShowPermsService Intent { act=android.intent.action.UNINSTALL_PACKAGE cmp=com.google.android.wearable.app/com.google.android.clockwork.packagemanager.ShowPermsService (has extras) } for com.sergio.application
表示无法安装应用程序,但没有提供问题的详细信息,只显示错误代码 -103 。
我已经考虑了应用程序磨损开发的基本考虑因素。
主应用程序和SmartWatch都具有相同的功能 申请ID。。
SmartWatch应用程序中所需的权限也是 在主应用程序中明确配置。
等。
该应用程序可以直接在Android Studio中以“独立”模式正确实施。
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'
//apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.sergio.application"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
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:animated-vector-drawable:${rootProject.support_library_version}"
implementation "com.android.support:appcompat-v7:${rootProject.support_library_version}"
implementation "com.android.support:recyclerview-v7:${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.2.0'
compileOnly 'com.google.android.wearable:wearable:2.2.0'
implementation 'com.patloew.rxwear:rxwear:1.3.0'
implementation 'uk.co.chrisjenx:calligraphy:2.3.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;
}
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
使用的版本:
support_library_version = "27.1.1"
constraint_layout_version = '1.1.0'
play_services_version = "15.0.0"
接下来,我将展示应用程序的清单文件。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sergio.application">
<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="api_key"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="api_key" />
<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"/>
</application>
</manifest>
有人可以帮我解决这个问题吗? 。谢谢。
答案 0 :(得分:0)
一切都是由于混乱,我已经明白,当为app模块生成“发布”编译时,配置使apk签名(密钥库,别名,密码)传播到模块磨损。从 Android Studio 生成apk时我没有问题,从CLI ./gradlew assembleRelease
生成apk时出现错误103
因此解决方案非常简单
在模块磨损的平台中包含以下配置:
signingConfigs {
release {
storeFile file("./keystore_secret")
storePassword "myPassword"
keyAlias "MyAlias"
keyPassword "myPassword"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
我希望它对某人也有用。