我最近在gradle build / sync上收到此错误消息:
当我点击“打开文件”时,它会切换到 build.gradle(App)窗口。
我没有在stackoverflow上获得任何解决方案。请检查代码并告诉我这个问题。
我真的很感谢你的帮助。
build.gradle(项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
google()
}
dependencies {
/*compile('javax.inject:javax.inject:1',
'com.google.dagger:dagger:2.7',
'de.greenrobot:eventbus:2.2.1',
'io.reactivex:rxjava:1.2.0',
'io.reactivex:rxandroid:1.2.1')
compile files('libs/publisher-sdk-android-5.1.0.jar')*/
}
}
build.gradle(App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.appname"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
//multiDexEnabled = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}*/
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
// Vungle SDK
//implementation 'com.github.vungle:vungle-android-sdk:6.2.5'
// Optional Google Play Services - Location and Basement
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
//Replace it with Google Analytics?
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'org.jsoup:jsoup:1.8.3'
implementation 'com.github.simbiose:Encryption:2.0.1'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:2)
使用这些
先检查
转到设置/偏好设置&gt; <构建,执行,部署选项>即时运行并取消选中所有三个框。
<强> 1 即可。升级Gradle服务URL:
项目&gt; Gradle&gt;包装器&gt; gradle-wrapper.properties
从
更改网址distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
到
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
(在此处查找最新的distributionUrl gradle插件版本:http://services.gradle.org/distributions
**确保使用gradle-x.xx-all.zip)
<强> 2 即可。删除您的构建文件夹
运行项目时,将自动创建构建文件夹
第3 即可。转到菜单中的BUILD选项&gt;清理项目,构建项目
它应该在没有即时运行的情况下工作。