I'm getting an error right after I installed Android studio and Created a simple app.
Steps followed:
Fresh download & installed Android studio.
Created a new project.
When the project loaded, The gradle failed with error:
Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Module Gradle File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "info.ankitjc.happybirthday"
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.1.0'
testCompile 'junit:junit:4.12'
}
Project Gradle File:
// 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.2.3'
// 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
}
I searched for possible solutions here.
Android compile error; Java plugin has been applied, not compatible with android
Gradle error "Java plugin is not compatible with android plugins"
After File > Invalidate Cache/Restart
I think path has not been set as enviorment variable.
check have you declared the java sdk path . set the path as environment variable.
type "javac" in cmd(cmd must have admin previlliage).
If compile is not successfful
1 . Open the jdk location and copy the path of "bin"
2 . Open system properties in control panel.
3 . Advanced system settings -> then select "environment variables"
4 . click on "new"
5 . set variable name as "path" and variable value copied address
then try again
This means the Java plugin is being applied on top of the Android plugin. I don't see anything that stands out in your build files though. Some things to try:
Try doing a clean build from command-line. That will tell you if it's an Android Studio problem.
Create an empty app from a clean slate and see if it builds.
Update Android SDK to latest
Update Android Studio to the latest
Remove Android Studio project files and re-import
Make sure correct Java version is in your path and JAVA_HOME is set correctly
Check if there is any jars in your local lib folder that could be conflicting
Try using beta version of Android plugin compile 'com.android.tools.build:gradle:2.3.0-beta2'
I experienced this error while updating from KAPT to KSP. The docs say to add
id 'org.jetbrains.kotlin.jvm'
to the plugins block, but it appears that adding the Kotlin jvm plugin to the mix was causing my java plugin error. Remove the reference and it compiles. FYI the linked docs are more figurative than literal.
Not sure if this would help, but maybe you can try to explicitly add the java compilation option:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Try removing these two lines of code from your build.gradle
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
and
testCompile 'junit:junit:4.12'
Try this one
Procedure :-
1.right click on project ->Open Module Settings or F4
2.then goto SDK Location
3.after that Check on use embedded jdk(recommended)
you can see image given below
build and run project.
You can also add this in your build.gradle file
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
check if more than one jdk is installed.
Related
Any project in my android studio fails to build.The error message is as follows-
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. I found some answers saying right click on java folder then clicking Mark Directory as -> SOurce root, even this option is not there . 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.
build.gradle contents are-
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-
#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-
// 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-
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
the code in JUnit library is referenced in the project but there is no related JUnit dependent library yet...you either have to delete the referencing line(s) of code in the gradle or install the JUnit library.For more info https://debugah.com/failed-to-resolve-junitjunit4-12-how-to-solve-11544/
I have strange problem and don't know how to resolve it.
I have an interface with default method, like this:
public interface ITest{
default String getText(){
return "ITest";
}
}
and class which implements this interface, like this:
public class TestClasssss implements ITest{
private String text;
}
And I trying to use this class inside my app unit tests project.
So, if I copy this classes inside my android's unit test project it compiles ok and all working as expected, however if this class and interface declared in app source folder, application do not compile and crash with
Error:(30, 10) error: cannot access ITest bad class file: ~\ITest.class
default method found in version 50.0 classfile
Please remove or make sure it appears in the correct subdirectory of the classpath.
So, how could I fix this strange behaviour?
My graddle config looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
repositories {
mavenCentral()
mavenLocal()
maven {
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
}
}
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "io.projectname"
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
testOptions {
unitTests.returnDefaultValues = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
sourceSets {
main {
res.srcDirs =
[
'src/main/res/controls',
'src/main/res/fragments',
'src/main/res/activities',
'src/main/res/views',
'src/main/res'
]
}
}
}
ext {
JUNIT_VERSION = '4.12'
DAGGER_VERSION = '2.2'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.0.111-beta'
testCompile "org.robolectric:robolectric:3.1.1"
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.roughike:bottom-bar:1.3.4'
compile 'com.aurelhubert:ahbottomnavigation:1.2.3'
compile 'joda-time:joda-time:2.9.4'
compile 'com.annimon:stream:1.0.9'
compile 'com.kyleduo.switchbutton:library:1.4.1'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile('eu.davidea:flexible-adapter:5.0.0-SNAPSHOT') {
changing = true
}
compile 'com.github.aakira:expandable-layout:1.5.1#aar'
compile "cn.aigestudio.wheelpicker:WheelPicker:1.1.2"
compile 'net.sf.biweekly:biweekly:0.5.0'
//Dagger dependencies started
compile "com.google.dagger:dagger:$DAGGER_VERSION"
apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'javax.annotation:jsr250-api:1.0'
compile 'javax.inject:javax.inject:1'
testCompile "junit:junit:$JUNIT_VERSION"
testApt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
//Dagger dependencies finished
provided 'org.projectlombok:lombok:1.16.10'
}
Make sure that you set up source and target compatibility correctly
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I was dealing with the same issue, it appears to be some kind of conflict between the compiled java source version accepted on android and the output produced by the code compiled with retrolambda.
The problem raises when you use the default notation for funcional interfaces method.
There's some kind of limited support for that in the retrolambda plugin, quoting the readme of the repo (orfjackal/retrolambda):
retrolambda.defaultMethods
Whether to backport default methods and static methods on interfaces.
LIMITATIONS: All backported interfaces and all classes which implement
them or call their static methods must be backported together,
with one execution of Retrolambda.
Disabled by default. Enable by setting to "true"
So you can try using this in your android module's build.gradle file:
...
android {
...
}
retrolambda {
defaultMethods = true
}
In my case this does not work, but my scenario was quite different than yours. I was having the retrolambda code on one library project and then trying to use that on another app project.
Also I could not get the Jack & Jill compiler to work (theres some kind of java8 support with Jack enabled, see Enable Java 8 Features and the Jack Toolchain at android reference), one cryptic "NullPointer" raises at ./gradlew assembleDebug, so I suggest to avoid jackOptions for now.
Good luck!
I think that you probably need to enable the Jack compiler. You need the following:
Android Studio > 2.1
Default methods are only available if you are targetting API Level 24
Your gradle needs to look something like this:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
This is the Java 8 Language Feature Page in the Android Documentation
I had this issue after using dex2jar. According to https://gitlab.ow2.org/asm/asm/blob/master/asm/src/main/java/org/objectweb/asm/Opcodes.java#L264, version 50 of the JVM bytecode represents Java 1.6, while my dex file was designed to run on version 52 (1.8). I used another dex2jar utility (which should work on any jar, not just dex) to change the version to 1.8. The source is at https://github.com/pxb1988/dex2jar/blob/2.x/dex-tools/src/main/java/com/googlecode/dex2jar/tools/ClassVersionSwitch.java, the command is d2j-class-version-switch.sh 8 <source jar> <destination jar>.
Are you sure that your gradle build is using jdk1.8+? It seems like the build is trying to utilize a class that was built using 1.8 but being tested during build using a lower version.
try:
gradle clean build
OR
gradlew clean build
If you are using Android Studio try to Clean Project, then Build project. If it doesn't help too, then Click to File -> "Invalidate Caches / Restart". It must help
I try to import a project in Android studio. When importing it, i've got an Error with Gradle :
Gradle sync failed: Unable to find method
'org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;'.
I have tried :
Re-download dependencies and sync project: Fail (same error).
Stop Gradle build processes: Fail (same error).
Delete the .graddle in the home directory: Fail (same error).
Invalidate cache and restart Fail (same error).
Uninstall and reinstall Android studio and SDK: Fail (same error).
/build.gradle :
// 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.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
/app/build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'xxx.xxx.xxx'
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildPB {
debuggable false
jniDebuggable false
renderscriptDebuggable false
zipAlignEnabled true
}
}
productFlavors {
}
// lintOptions {
// abortOnError false
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile ('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'net.sf.opencsv:opencsv:2.3'
compile 'de.greenrobot:greendao:1.3.7'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// compile 'com.android.support:support-v4:19.+'
}
I fixed the error by changing the following things.
Open the file under your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties
replace the old URL path by this one:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Rename the folder name from "...\1.12" to your-app-project\your-app-name\.gradle\2.10
Change the classpath of your-app-project\your-app-name\build.gradle to
classpath 'com.android.tools.build:gradle:2.1.2'
Replace runProguard of your-app-project\your-app-name\app\build.gradle by minifyEnabled
Click Retry on the error reminder or Reopen your Android Studio and project.
I am using the latest versions of Android Studio and Gradle.
edit Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-bin.zip
rebuild the project (restart ide in your mind)
Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
https\://services.gradle.org/distributions/gradle-4.1-all.zip
This will surely work. I was having same issue. Solved by this.
This issue appears when I updated my android studio to 3.1.1
1.
I have resolved it by changing:
classpath 'com.android.tools.build:gradle:3.1.1'
in build.gradle (project)
2.
change:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
in gradle-wrapper.properties.
(you can check it in explorer C:\Program Files\Android\Android Studio\gradle\gradle-4.4)
I faced similar issue and i resolved it by
Android Studio Version 3.0.1
1.Change the classpath of your-app-project\your-app-name\build.gradle to classpath 'com.android.tools.build:gradle:3.0.1'.
2.Replace the old URL path by this one: distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
My gradle file was of version 4.1
ie; file in following location:(may differ slightly in your machine)
C:\Program Files\Android\Android Studio\gradle\gradle-4.1
Under gradle->gradle-wrapper.properties
replacing
distributionUrl=https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip
with
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.1-all.zip
solved the issue.
This issue happened to me today with Android Studio 2.2 Beta2 on Windows 7 64-bit.
None of the solutions mentioned helped. Finally I was able to resolve the issue by re-importing my project.
For me the solution was to open Settings -> Build, Execution, Deployment -> Gradle and check "Use default gradle wrapper (recommended)".
I was able to copy over the /.gradle folder from a new Android project into the one that was having the problem. Then I restarted Android Studio and did a clean/build. This resolved my issue.
After 1 hour R&D Not Solution as worked for me...
But still i have solution follow this its work 100
step 1: upgrade your build.gradle(Project:<your project name>)
Example : classpath 'com.android.tools.build:gradle:2.1.3' // old gradle file
classpath 'com.android.tools.build:gradle:2.3.1' // upgraded file
OR
classpath 'com.android.tools.build:gradle:3.1.0'
Step 2 : Upgrade compileSdkVersion buildToolsVersion
Example : compileSdkVersion 23 buildToolsVersion "23.0.3 // old api's
compileSdkVersion 25 buildToolsVersion "25.0.2" // upgraded api's
Step 3: upgrade gradle-wrapper.properties
Example : distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip // old or any version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // new or any version
Step 4 : finally goto build>rebuild project...
......End #Ambilpura
The answer is partially reduntant, but it's for those who are confused with what version of gradle distribution to add.
It's the gradle version that's installed on your machine.
Ex:
Check your gradle version by:
"gradle -v" (mine was 5.4.1)
Update the file "your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties" with
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
And done! It solved the problem for me.
Summary:
I have an AAR file that depends on a JAR file, when I build the AAR project, it doesn't contain the JAR code.
Details:
I have a Java SDK library project that contains code that we use for Java web projects and such, this library is created using Gradle and resides in an internal nexus server (as a JAR).
The goal is to provide an "Android configured" version of this JAR library through an AAR library that multiple Android Applications can use and minimize the effort (and boilerplate code) to implement it. This AAR file is also uploaded to the nexus server to be used by the Android Application projects.
My AAR project includes a gradle dependency for my Java SDK library (the JAR) but when built, the AAR doesn't include any classes from it.
Code:
This is the Java SDK project's gradle file:
apply plugin: 'java'
//noinspection GroovyUnusedAssignment
sourceCompatibility = 1.7
version = '1.1.1'
repositories {
mavenCentral()
}
jar {
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'org.springframework:spring-web:3.1.1.RELEASE'
compile 'com.google.code.gson:gson:2.3'
}
This is the gradle file for my AAR Project, note that I removed the Maven repository declarations to my nexus server from it. I guess it shouldn't matter for the sake of this question.
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "2.2.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile ('com.mycompany:javasdk:1.1.1')
}
This is the gradle file for my Android Project, again I removed the nexus server references:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.mycompany.application1"
minSdkVersion 16
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.1.0'
compile ('com.mycompany:androidsdk:2.2.2#aar')
}
NOTE: I initially solved the issue by adding the JAR in the lib directory of the AAR project, but this is undesired. It makes having a nexus server useless. It would be good that we can just bump the JAR's version number in the AAR project's gradle file and the update happens automatically at compile time.
NOTE2: I tried adding transitive=true to my AAR dependency in the Android Project but it didn't solved anything, the real issue is that when building the AAR project, the JAR project code doesn't get bundled.
You can add this task:
task copyLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Dependencies will be downloaded from your Nexus, but when you need package the library, execute this task first and jar files will be copied and included inside final aar.
By default, AAR does not include any dependencies. Solution mentioned by #Hector should work for gradle plugin < 3.0. For Gradle plugin 3.0+, try custom config as mentioned here.
android { ... }
// Add a new configuration to hold your dependencies
configurations {
myConfig
}
dependencies {
....
myConfig 'com.android.support:appcompat-v7:26.1.0'
myConfig 'com.android.support:support-v4:26.1.0'
...
}
task copyLibs(type: Copy) {
from configurations.myConfig
into "libs"
}
None of the suggestions helped me for Gradle 4.6, so I wasted the whole day inventing my own.
Eventually I found a good Gist and modified it for my version of Gradle:
https://gist.github.com/stepio/824ef073447eb8d8d654f22d73f9f30b
The upper ones didn't work for me in android tools 3.6.2 with Gradle. 5.6.1 . For anyone having the same issue, using https://github.com/kezong/fat-aar-android in the end worked fine for me.
Whenever I add a dependency from an remote repository (jcenter) in Android Studio 1.1 (OS X) I get the following error upon syncing Gradle:
Error:(26, 13) Failed to resolve: <packagename:version>
My app's build.gradle is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "nl.timmevandermeer.cargoapp"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.json:json:20141113'
}
I have tried changing repositories (jcenter(), mavenCentral(), etc.), reinstalling Android Studio, JDK (7 and 8), changing Gradle version and Android SDK version, none of which worked. Upon running ./gradlew build I get:
Could not resolve com.android.tools.build:gradle:1.1.0.
13:48:04.914 [ERROR] [org.gradle.BuildExceptionReporter] Required by:
13:48:04.915 [ERROR] [org.gradle.BuildExceptionReporter] :CargoApp:unspecified
13:48:04.932 [ERROR] [org.gradle.BuildExceptionReporter] >
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
This is an error I get in other cases as well, for example when trying to use Intellij Idea instead of Android Studio. Running the app without the dependency does work though.
A similar problem here, and when I choose Build -> Clean Project
there is a "peer not authenticated" error.
solved by using "http://jcenter.bintray.com/" instead of "https://jcenter.bintray.com/"
repositories {
jcenter({url "http://jcenter.bintray.com/"})
}
hope this work for you.
I had a similar problem with a library on github, which stated to install it as:
dependencies {
compile 'com.github.chrisbanes.photoview:library:1.2.4'
}
This workaround seem to work, although it's suboptimal because it doesn't fetch a specific version and leads to Android Studio warnings:
dependencies {
compile 'com.github.chrisbanes.photoview:library:+'
}
In my case, the problem was I was declaring jitpack in buildscript.repositories instead of allprojects.repositories in my package build.gradle.
Instead of:
buildscript {
repositories {
...
maven {
url "https://jitpack.io"
}
}
}
It should be here:
allprojects {
repositories {
...
maven {
url "https://jitpack.io"
}
}
}
Rather late but probably your gradle works in offline mode.
Go to File->Settings->Gradle and uncheck the offline mode.
Then try to refresh gradle and it should work
I am behind a corporate firewall. I had my http settings set, but not my https settings. So, I added the following to my gradle.properties file:
systemProp.https.proxyPassword=...
systemProp.https.proxyHost=...
systemProp.https.nonProxyHosts=...
systemProp.https.proxyUser=...
systemProp.https.proxyPort=...
When I added this com.droidninja:filepicker:2.2.5 dependency in my build.gradle (Module Level) file then I got this error.
Failed to resolve: com.droidninja:filepicker:2.2.5
Then I added gradlePluginPortal() in settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Add this line
gradlePluginPortal()
}
}
It worked for me.
Top build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
App build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "nl.timmevandermeer.cargoapp"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
// compile fileTree(dir: 'libs', include: ['*.jar']) // <-- use gradle depedencies
compile 'com.android.support:appcompat-v7:22.0.0' // <-- brings in v4
// compile 'com.google.android.gms:play-services:7.0.0' // <-- will cause MultiDex exception, you need to choose which ones you want
// compile 'org.json:json:20141113' // <-- android comes with org.json
}
Multi-Dex Issue:
compile 'com.google.android.gms:play-services:7.0.0' is too big and should not be used directly. Please choose the modules you want here: http://developer.android.com/google/play-services/setup.html
I have similar problem -> ERROR: Failed to resolve:
solved by using maven { url 'https://jitpack.io' } instead of
maven {url 'https://maven.google.com/'}
I have added it in project level build.gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
It works fine.
Tested in UBUNTU - 14.04 ,
>delete .androidstudio1.2 , .gradle , .android , Android studio project from home directory
> Launch using studio.sh
>close the dialogue letting you choose new or old setting , just close it using that "x " button
> then it will set up an virtual nexus 5
>then there will be two errors saying problem about "sdk" and "gradle "
> Caution : choose the appropriate sdk version by clicking on the link given by where the problem is shown .
> close android studio
> reopen android studio
> then you will be thrown a possible error with jdk not found .
>go to file -> project structure
> give the path to jdk , in my case its "usr/local/java/jdk..."
>close android studio and open again , the gradle might work well after this .
In my case I added this to my build.gradle (module:app):
compile 'com.github.glomadrian:velocimeterlibrary:1.1#aar'
However, it gave me an error today. My solution is to use this instead:
compile 'com.github.glomadrian:velocimeterlibrary:+'