[英]how to solve the gradle error
你好,我真的需要一些幫助我的項目gradle ...我是android studio中的新手,現在我遇到了gradle問題。 拜托我...
它是我的gradle代碼(項目:)
buildscript {
repositories {
apply plugin: 'java'
apply plugin: 'announce'
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
和我的gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.shoaib.newsletters"
minSdkVersion 18
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'
}
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'
compile 'com.tomerrosenfeld.customanalogclockview:custom-analog-clock-view:1.1'
compile 'com.android.volley:volley:1.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
現在我的消息gradle Sync是
Error:(7, 0) Gradle DSL method not found: 'google()'
Possible causes:<ul><li>The project 'NewsLetters' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
現在我在本地使用Gradle 3.2.1請幫助我:(
使用gradle 3.1.2
,而不是3.2.1
,除非您絕對必須擁有3.2.1
。
當我嘗試使用gradle 3.2.1進行構建時,它失敗了,說:
找不到com.android.tools.build:gradle:3.2.1。
看來您使用的Gradle版本低於4.1。 更改gradle-wrapper.properties
的分發URL,如下所示:
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.8-all.zip
要找到gradle-wrapper.properties
文件,請在Android Studio中按ctrl + shift + N
並鍵入gradle-wrapper
更改依賴關系,如下所示:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
目前,Android Studio 3.2處於不穩定狀態。 其處於金絲雀釋放狀態。 所以它的gradle插件處於alpha狀態
classpath 'com.android.tools.build:gradle:3.2.0-alpha17'
此版本的gradle插件在Android Studio 3.2 Canary17中可用
如果要使用穩定版本,請下載Android Studio 3.1.3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.