我想将com.google.android.gms:play-services-location:16.0.0
添加到我的Android Wear应用中以检测手表的位置。
但是我遇到以下错误:
Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:percent:26.0.2] AndroidManifest.xml:25:13-35
is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override.
我的wear.gradle
文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "de.siyaryikmis.jiyan"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:wear:28.0.0'
implementation 'com.google.android.support:wearable:2.4.0'
compileOnly 'com.google.android.wearable:wearable:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
我的wear.AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="de.siyaryikmis.jiyan">
<uses-feature android:name="android.hardware.type.watch" />
<uses-feature
android:name="android.hardware.sensor.accelerometer"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/tree_of_life"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name" />
<activity
android:name=".activities.LoginActivity"
android:label="@string/title_activity_login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.Login2Activity"
android:label="@string/title_activity_login2"
android:theme="@android:style/Theme.DeviceDefault.Light" />
<activity
android:name=".activities.NeedIsSentActivity"
android:label="@string/title_activity_need_is_sent"
android:theme="@android:style/Theme.DeviceDefault.Light" />
<activity
android:name=".activities.FailedActivity"
android:label="@string/title_activity_failed"
android:theme="@android:style/Theme.DeviceDefault.Light" />
</application>
</manifest>
感谢您的所有建议和帮助:)
答案 0 :(得分:3)
首先添加工具名称空间:
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">#your-color-here </item>
</style>
</resources>
然后添加元标记:
< manifest xmlns: android = "http://schemas.android.com/apk/res/android"
...
xmlns: tools = "http://schemas.android.com/tools" >
别忘了在模块build.gradle文件中添加以下行:
<application>
...
..
<meta-data
tools:replace="android:value"
android:name="android.support.VERSION"
android:value="28.0.0" />
</application>