Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Fails to Sync even on first run

i installed Android Studio latest version on windows 10.(what i already did with another version and another windows 10) it's OK with android SDK but when it wants to load a project it said this:

Error:(23, 17) Failed to resolve: junit:junit:4.12

and here's the log:

JsonSyntaxException: Parse exception while reading distributions.json: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

gradle.build file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.mohammad.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
}
like image 639
WiGeeky Avatar asked May 15 '16 05:05

WiGeeky


People also ask

Why is my Gradle not syncing?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.

What does Gradle project sync failed mean?

Android Developers get "Gradle project sync failed" or "Gradle sync failed" error in Android Studio when project gradle is unable to sync properly. This maybe caused due to a number of reasons including incorrent versions in project settings, corrupt cache, network problems and wrong dependencies. Gradle sync fail error happens commonly due to ...

How to fix Android Studio won’t open Gradle files?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.

Why is the online Gradle distribution not working?

We came across several cases where the online distribution was not working as expected and failed the Gradle sync. Another workaround to this issue is to download the Gradle distribution manually and make use of that. Follow the steps below: Download the latest version of Gradle from the official Gradle Release Website.

How do I restart a Gradle project in Ubuntu?

1 Method 1: Restarting your project using Invalidate Caches and Restart option. In this method, we will be restarting our project using Invalidate Caches and Restart option. ... 2 Method 2: Sync your project with Gradle files. ... 3 Method 3: Deleting and installing new Gradle files. ...


Video Answer


1 Answers

add the following lines

android {
 ...
 ...
repositories {
    maven { url 'http://repo1.maven.org/maven2' }
}
...
...
}
like image 155
Mrugesh Thaker Avatar answered Sep 22 '22 23:09

Mrugesh Thaker