我将 Android Studio 更新到了 3.1 版,将我的项目的 Gradle 更新到了 3.1.0 版。
从那时起,我遇到了一些与合并多个文件相关的问题,但我能够解决。
然后我有这个错误:
> Manifest merger failed :
Attribute activity#com.aware.ui.PermissionsHandler@launchMode
value=(singleTop) from [com.awareframework:aware-core:4.0.555]
AndroidManifest.xml:35:13-43 is also present at
[com.github.denzilferreira:aware-client:4.0.555]
AndroidManifest.xml:44:13-42 value=(standard).
Suggestion: add 'tools:replace="android:launchMode"' to <activity>
element at AndroidManifest.xml:30:9-37:66 to override.
所以,首先我尝试使用
tools:replace="android:launchMode"
在提到的 Activity 中:<activity android:name=".MainActivity"
...
tools:replace="android:launchMode"
android:launchMode="standard">
</activity>
但它并没有解决问题,然后我搜索并发现了一些类似的问题和他们的回答。
其中一位说要从有冲突的库中删除建议的属性:
<activity
android:name="com.aware.ui.PermissionsHandler"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleTop" //deleted this line from Manifests
android:noHistory="true"
android:theme="@style/Theme.AppCompat.Translucent" />
但又一次,没有成功。我也尝试使用
tools:replace="android:launchMode"
在应用程序标签内:<application
...
tools:replace="android:launchMode">
然后使用
android:launchMode="standard"
在 Activity 标签内。<activity android:name=".MainActivity"
....
android:launchMode="standard">
</activity>
但它会引发不同的错误:
tools:replace specified at line:16 for attribute android:launchMode,
but no new value specified
我还尝试重新排序 Gradle 文件中的依赖项,例如 @GLee 回答 here但这没有任何区别。
这是我正在使用的有冲突的库之一:Aware Activity Recognition Plugin .
这是我用来创建应用程序的教程:Creating a standalone application .
另一个相关的事情是,两个冲突的依赖关系在不同的模块中,
com.awareframework:aware-core:4.0.555
依赖在 app 模块和 com.github.denzilferreira:aware-client:4.0.555
位于 activity_recognition 模块内。最后,这是我的 App Gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "app.miti.com.iot_reduce_daily_stress_application"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
...
}
dependencies {
...
implementation "com.awareframework:aware-core:${aware_libs}"
implementation "com.android.support:appcompat-v7:${support_libs}"
implementation "com.android.support:cardview-v7:${support_libs}"
implementation "com.google.android.gms:play-services-location:${gms_libs}"
implementation "com.google.android.gms:play-services-maps:${gms_libs}"
implementation "com.google.android.gms:play-services-places:${gms_libs}"
implementation 'com.android.support:preference-v14:${support_libs}'
implementation "com.android.support:design:${support_libs}"
implementation 'pub.devrel:easypermissions:1.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation "com.google.firebase:firebase-core:${firebase_libs}"
implementation "com.google.firebase:firebase-messaging:${firebase_libs}"
...
}
这是我的 activity_recognition 模块 Gradle 文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode version_code
versionName version_readable
multiDexEnabled true
}
...
}
dependencies {
...
implementation "com.google.android.gms:play-services-location:${google_libs}"
implementation "com.android.support:appcompat-v7:${support_libs}"
api "com.github.denzilferreira:aware-client:${aware_libs}"
implementation "com.koushikdutta.ion:ion:2.1.6"
implementation "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2"
}
这是 App AndroidManifest.xml(错误 URL 指向此文件):
<?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="app.miti.com.iot_reduce_daily_stress_application">
... //permissions
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:parentActivityName=".MainActivity"
tools:ignore="UnusedAttribute">
</activity>
</application>
</manifest>
由于这不是依赖版本问题,就像我发现的许多其他问题一样,并且因为我必须在我的项目中使用这个库依赖关系,我该如何解决这个问题?
P.S:我已经尝试过常用的方法:
最佳答案
问题在于 com.aware.ui.PermissionsHandler
,这就是为什么将属性放在 .MainActivity
上的原因无济于事,因为这是一项不同的 Activity 。由于您在发布的 Gradle 文件中使用了工件,因此我不确定您在哪里修改了库的 list 。
在您的应用 list 中,添加:
<activity
android:name="com.aware.ui.PermissionsHandler"
android:launchMode="..."
tools:replace="android:launchMode"
/>
在哪里
...
是你想要的launchMode
值,也许在与这些库的开发人员讨论以确定正确答案是什么之后。您不应该需要任何其他属性或子元素——它们都应该通过 list 合并过程合并。
关于android - list 合并失败错误(工具 :replace ="android:launchMode"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49807490/