每当我将
implementation 'com.google.android.gms:play-services-ads:22.6.0'
添加到我的构建中时,我都会收到错误:gradle(应用程序)
这是我的构建代码:gradle(应用程序):
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
repositories {
google()
jcenter()
mavenCentral()
}
android {
namespace 'com.sp.moneyminds'
compileSdk 34
defaultConfig {
applicationId "com.sp.moneyminds"
minSdk 27
targetSdk 33
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
allprojects {
tasks.withType(JavaCompile){
options.compilerArgs<<"-Xlint:deprecation"
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-auth:22.3.0'
implementation 'com.google.firebase:firebase-database:20.3.0'
implementation 'com.google.android.gms:play-services-auth:20.7.0'
implementation 'com.google.firebase:firebase-firestore:24.10.0'
implementation 'com.google.firebase:firebase-storage:20.3.0'
implementation 'com.google.firebase:firebase-messaging:23.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation platform('com.google.firebase:firebase-bom:32.7.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
implementation 'com.firebaseui:firebase-ui-database:7.1.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'androidx.work:work-runtime:2.7.0'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.lifecycle:lifecycle-common:2.5.1'
implementation 'com.google.android.gms:play-services-ads:22.6.0'
}
这是我的构建代码:gradle(项目):
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.2' // Updated to the latest version
classpath 'com.google.gms:google-services:4.4.0'
}
}
plugins {
id 'com.android.application' version '8.2.2' apply false // Updated version
id 'com.google.gms.google-services' version '4.4.0' apply false
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
这是我同步时遇到的错误: 无法解析:com.google.android.gms:play-services-ads:22.6.0 在项目结构对话框中显示 显示详细资料 受影响的模块:app
我已经排查问题三天了。请帮忙
我尝试过 chatgpt 并使用不同版本的广告实现,但没有成功
试试这个 使
targetSdk 34
与 compileSdk 34
相同
并删除你旧的添加
implementation 'com.google.android.gms:play-services-ads:22.6.0'
并添加这个
implementation group: 'com.google.android.gms', name: 'play-services-ads', version: '22.6.0'
请尝试此操作并发送告诉我结果
我使用了旧版本的实现并且它有效。具体来说是版本 20.0.0。我发现由于某种原因,比该版本更新的版本在我的应用程序中不起作用。