Ani*_*gri 10 android gradle android-studio build.gradle android-gradle-plugin
我收到此错误:这是我的build.gradle(模块:app)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding.enabled = true
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
compileOnly "org.projectlombok:lombok:1.16.20"
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-places:15.0.0'
implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
这是我的build.gradle(Project:myApp)
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'io.fabric.tools:gradle:1.25.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
我已经检查了其他解决方案,其中大多数建议添加
maven { url "https://maven.google.com" }
to build.gradle of project.我已经尝试了这个,但我仍然得到同样的错误.
我在android studio 3.0上.我也试过添加google()
而不是maven(另一个建议)
选项1:
请按照以下说明解决。
项目级 build.gradle
用
maven { url "https://www.jitpack.io" }
Run Code Online (Sandbox Code Playgroud)
代替
maven { url "https://jitpack.io" }
Run Code Online (Sandbox Code Playgroud)
选项 2:
项目级 build.gradle
google()
存储库应该是第一优先级
allprojects {
repositories {
google()
mavenLocal()
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
选项 3:
请按照以下步骤解决。
第1步:
项目级 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" } // For Ucrop
maven { url "https://maven.google.com" } // Google's Maven repository - FCM
maven {
url 'https://dl.bintray.com/azeesoft/maven'
}
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
第2步:
应用级 build.gradle
我有更新 One Signal 版本。
用
implementation 'com.onesignal:OneSignal:3.11.1'
Run Code Online (Sandbox Code Playgroud)
代替
implementation 'com.onesignal:OneSignal:3.10.9'
Run Code Online (Sandbox Code Playgroud)
去 File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Build Tools -> Gradle ->
并取消选中Offline work
选项.
我在使用 OneSignal 处理我的 android 应用程序中的推送通知时遇到了同样的问题。
解决方案是将 exclude 子句添加到其依赖项中:
implementation ('com.onesignal:OneSignal:3.8.3'){
exclude group: 'com.google.android.gms'
}
Run Code Online (Sandbox Code Playgroud)
在 app 文件夹中,然后手动添加任何其他缺少的依赖项,例如:
implementation 'com.google.android.gms:play-services-appinvite:16.1.0'
Run Code Online (Sandbox Code Playgroud)
问题是 OneSignal SDK 包含的 Google Play 服务依赖项与我在应用程序中使用的最新版本的 gms 和 firesbase 的版本不同。
所以我建议你找出你添加的一个在项目中使用 google play 服务的依赖项,并在其上使用 exclude 子句。尽管如果您的系统连接到互联网,您的 gradle 应该会构建。
希望这是有帮助的。
小智 -2
您是否尝试过将其添加到您的依赖项中:
implementation 'com.google.android.gms:play-services-basement:15.0.0'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12116 次 |
最近记录: |