我在编译代码时遇到了这个错误:
<!-- language: lang-none -->
Program type already present:
com.google.android.material.internal.package-info
Message{kind=ERROR, text=Program type already present:
com.google.android.material.internal.package-info, sources=
[Unknown source file], tool name=Optional.of(D8)}
当我搜索类似的错误时,建议添加 。
configurations {all*.exclude group: 'com.android.support', module: 'support-v13'}
或者将以下几行代码添加到“gradle.properties”文件中。
android.useAndroidX = true
android.enableJetifier = false
但是这些解决方案都不适用于我,这是我的Gradle文件。
app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.agh.yaomi"
minSdkVersion 17
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v13'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// added meta data in manifiest to resolve
//suppport version conflict
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:support-annotations:28.0.0-beta01'
implementation "org.jetbrains.anko:anko:0.10.4"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-media-compat:28.0.0-alpha3'
// added to solve merge dex error
implementation 'com.android.support:multidex:1.0.3'
implementation ('com.github.omadahealth:lollipin:2.1.0@aar') {
transitive = true
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
项目
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven{ url "https://github.com/omadahealth/omada-nexus/raw/master/release" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
有什么建议吗?