我尝试了不同的方法,但问题没有解决,我甚至重新安装了android studio但仍然遇到同样的问题:
>>> Point = namedtuple('Point', ['x', 'y'])
>>> p = Point(11, y=22) # instantiate with positional or keyword arguments
>>> p.x + p.y # fields accessible by name
33
应用\的build.gradle
[Fatal Error] annotations-26.1.1.pom:2:1: Content is not allowed in prolog.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'myapp'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools:annotations:26.1.1.
Required by:
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.databinding:compilerCommon:3.1.1
> Could not resolve com.android.tools:annotations:26.1.1.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
> Content is not allowed in prolog.
> Could not resolve com.android.tools:annotations:26.1.1.
Required by:
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.build:builder-model:3.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:common:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:shared:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools.analytics-library:tracker:26.1.1
project : > com.android.tools.build:gradle:3.1.1 > com.android.tools.build:gradle-core:3.1.1 > com.android.tools.build:builder:3.1.1 > com.android.tools:sdklib:26.1.1 > com.android.tools.layoutlib:layoutlib-api:26.1.1
> Could not resolve com.android.tools:annotations:26.1.1.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/annotations/26.1.1/annotations-26.1.1.pom
> Content is not allowed in prolog.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 34s
项目(build.gradle)
//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项。
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.kakarot.myapp"
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
}
我添加了app模块build.gradle和project build.gradle。
答案 0 :(得分:2)
经过大量的努力和在线搜索,我终于解决了问题。
我删除了gradle中的所有缓存文件夹以及构建新项目的时间。它像魔术一样工作。 感谢 @ישואוהבאותך的回复并试图帮助我。
答案 1 :(得分:0)
适用于Android Studio 3.0.1。
关闭android studio(如果已经打开),然后删除这些目录的所有内容。
C:\Users\USER_NAME\.gradle\caches
C:\Users\USER_NAME\.android\build-cache
C:\Users\USER_NAME\.android\cache
启动Android Studio,看看神奇。
请注意,第一次加载需要一点时间。
答案 2 :(得分:0)
我通过删除 .gradle 文件夹中的缓存文件夹解决了这个问题。这是唯一有效的方法(它也适用于 android studio canary)