比方说大家遇到类似:
The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER
Can't install because provider name ****
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER
List of apks:
[0] '/Users/apple/Desktop/Projects/***/app/build/outputs/apk/stag/debug/***.apk'
Installation failed due to: 'INSTALL_FAILED_CONFLICTING_PROVIDER: Package couldn't be installed in /data/app/***-Pm0MCO2fW8Jc9qlCFbEPtw==: Can't install because provider name ***.provider (in package com.knowin.launcher) is already used by ***'
Retry
类似这种就是由于出现了依赖冲突造成的,这里遇到的是manifest重复注册了provider的name重复的两个apk。
遇到这种不要慌, ./gradlew :app:dependencies > dependence.txt 使用gradle命令查看dependencies依赖树,我这里使用了重定向,如果不想使用重定向直接命令 ./gradlew :app:dependencies就OK了。
如果遇到以下警告不要慌,咱们有解决办法:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
打开gradle.properties文件:
org.gradle.java.home=/Applications/Android Studio.app/Contents/jre/Contents/Home
加上这句就可以了路径相信大家都能找到,我就不多说了。找不到的可以留言。
最后就是修改build.gradle
implementation("com.***:***:${rootProject.ext.Version}") {
exclude group: 'com.***.**', module: '***'
}
完美解决,可以重新编译安装了。