[英]Unable to build gradle and create java class
Any project in my android studio fails to build.The error message is as follows-我的 android studio 中的任何项目都无法构建。错误消息如下 -
Gradle sync failed: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.3-all.zip'.
Consult IDE log for more details (Help | Show Log)
Moreover i'm unable to make a new java class in android studio by File->new->Java class as no such option is available.此外,我无法通过 File->new->Java 类在 android studio 中创建新的 java 类,因为没有这样的选项可用。 I found some answers saying right click on java folder then clicking Mark Directory as -> SOurce root, even this option is not there .我发现一些答案说右键单击 java 文件夹,然后单击 Mark Directory as -> SOURce root,即使这个选项不存在。 Moreover, for resolving the gradle issue, i found some answers saying click File->Invalidate Caches/Restart and delete the .gradle file in home directory then update android studio, i did accordingly but still nothing works.此外,为了解决 gradle 问题,我找到了一些答案,点击 File->Invalidate Caches/Restart 并删除主目录中的 .gradle 文件,然后更新 android studio,我做了相应的操作,但仍然没有任何效果。 build.gradle contents are- build.gradle 内容是-
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.iitmandi"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
testCompile 'junit:junit:4.12'
}
Contents of gradle-wrapper.properties are- gradle-wrapper.properties 的内容是-
#Tue Mar 28 20:10:53 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Build.grale-构建.grale-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
on doing Build->Clean project this error message was shown-在执行 Build->Clean project 时显示此错误消息-
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugUnitTestApkCopy'.
> Could not resolve junit:junit:4.12.
Required by:
project :app
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out
I even uninstalled Android-Studio 2.3 and installed 2.2.2 instead but still the problem persists我什至卸载了 Android-Studio 2.3 并安装了 2.2.2 但问题仍然存在
项目中引用了 JUnit 库中的代码,但还没有相关的 JUnit 依赖库...您必须删除 gradle 中的代码引用行或安装 JUnit 库。有关更多信息https:/ /debugah.com/failed-to-resolve-junitjunit4-12-how-to-solve-11544/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.