gradle errors in android studio
Gradle is a build tool integrated in Android Studio: it downloads your project dependencies (the jar files you use in your code) from the maven repositories (maven is another well-known build tool with package dependencies capabilities and a remote ecosystem of repositories). One of the most used repository is jcenter().
Your gradle file lack of a repository configuration: add this piece of code to your gradle file (/home/jeevansai/AndroidStudioProjects/MyApplication/app/build.gradle
): between apply plugin
and android {...}
section.
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 21
...
Alternatively, if you does not code the unit tests at the moment, you can simple comment out the junit dependency on the app/build.gradle
file:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Anyhow, you can always download the needed artifact from maven central and put in your /libs
directory:
wget 'http://central.maven.org/maven2/junit/junit/4.12/junit-4.12.jar' -O /home/jeevansai/AndroidStudioProjects/MyApplication/app/libs/junit-4.12.jar
Related videos on Youtube
identicon
Updated on September 18, 2022Comments
-
identicon almost 2 years
Error:(24, 17) Failed to resolve: junit:junit:4.12 "openFile:/home/jeevansai/AndroidStudioProjects/MyApplication/app/build.gradle"
The above mentioned error is appearing in Android Studio has many issues making a project. Can someone tell a solution to it.
output of
cat /home/jeevansai/AndroidStudioProjects/MyApplication/app/build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion '23.0.1' defaultConfig { applicationId "com.example.jeevansai.myapplication" minSdkVersion 8 targetSdkVersion 23 versionCode 1 versionName "1.0" } final def types = buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } types } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' }
output of
apt-cache policy junit4
junit4: Installed: 4.12-2ubuntu1 Candidate: 4.12-2ubuntu1 Version table: *** 4.12-2ubuntu1 0 500 http://in.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages 100 /var/lib/dpkg/status
-
AJefferiss over 8 yearsPost the contents of your gradle file so we can see what it's trying to do, but there's a possible solution on stackoverflow
-
A.B. over 8 yearsEdit your question and add the output of
cat /home/jeevansai/AndroidStudioProjects/MyApplication/app/build.gradle
-
identicon over 8 yearsintellij android studio , i did not do any configuration in it
-
identicon over 8 yearsOr someone provide me the link to download complete android sdk ,i mean all packages without the need for android studio to download.
-
-
identicon over 8 yearsnot working same error shows up
-
Giuseppe Ricupero over 8 yearsI've accessed now a project created with Android Studio: can you paste the content of the build.gradle in the directory above app:
/home/jeevansai/AndroidStudioProjects/MyApplication/build.gradle
-
Giuseppe Ricupero over 8 yearsI've updated my answer, waiting for your (project) root build.gradle, check if one of the solutions proposed works. The link to download the junit jar file can be found on a search engine of maven repos. I ofter use mvnrepository.com
-
hasanghaforian over 8 yearsI commented out the junit dependency and it works!