我正在构建一个应用程序,一切运行顺利。我的代码没有问题。 但是,只要在我的依赖项中添加“实现'com.google.android.gms:play-services-ads:19.1.0'”并进行同步,就会下载以下错误文件,并且gradle构建失败。
详细信息
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] lifecycle-livedata-core-2.0.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] core-runtime-2.0.0.pom:2:1: Content is not allowed in prolog.
Calling mockable JAR artifact transform to create file: C:\Users\Lenovo\.gradle\caches\transforms-2\files-2.1\dcf80f3e2f930bc6fa39c90f6616fd81\android.jar with input C:\Users\Lenovo\AppData\Local\Android\Sdk\platforms\android-28\android.jar
如果我没有在自己的亲戚家中写下“ com.google.android.gms:play-services-ads:19.1.0”,一切都很好
这是我的项目级别build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的应用程序级别build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId 'com.dictionary.anglobangla'
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'MissingTranslation'
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.13'
}
我尝试为实现“ com.google.android.gms:play-services-ads:17.1.0”提供实现,但仍然无法正常工作。
注意:我没有放置任何代码,因为所有代码运行顺利,没有广告依赖性。另外,由于gradle构建失败,我无法实施广告。
答案 0 :(得分:0)
最后,经过这么多搜索,我找到了答案的解决方案。
在项目级别构建gradle。
制作
buildscript {
repositories {
jcenter()
google()
}
为
buildscript {
repositories {
google()
jcenter()
}
并删除
.gradle\caches
// go to the folder where your project is located and delete
.gradle
.idea
all iml files
//if build folder is located in app folder delete it.