On creating a new Activity by
right-click on app > New > Activity > Empty Activity
Activity is created, but gradle file is auto-edited giving the error:
Error: Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
It happens same with Fragments. I'm using Android Studio 2.3.
How do I resolve this?
Code Sample:
// retrofit dependency
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
// charts
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
After creating Activity
compile
'com.google.code.gson:gson:2.7'compile
'com.squareup.retrofit2:retrofit:2.1.0'compile
'com.squareup.retrofit2:converter-gson:2.1.0'compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
The solution, for now, is to remove the comments inside the dependencies.
This question is asked a few times before. Here is the most recent one.
This is a bug possibly related to Java JDK and there is no possible solution, temporary solution is re-format your Gradle like this:
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
Related
When I initially used the code below in my build.gradle file, it helped me import the authentication.
compile 'com.google.firebase:firebase-auth:9.2.1'
After adding the below code to my build.gradle file
compile 'com.google.firebase:firebase-database:9.6.0'
Making me to have:
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-database:9.6.0'
together in my dependency, hence my authentication stopped working, displaying an error message in my MainActivity that I declared it.
"Cannot resolve symbol FirebaseUser" since FirebaseUser is what I named my import to be. Please help.
add same Dependencies version..
compile 'com.google.firebase:firebase-auth:9.6.0'
compile 'com.google.firebase:firebase-database:9.6.0'
I have recently started getting this issue with Android Studio and it has been driving me up the wall. I keep getting the error "Failed to resolve: com.squareup.okio:okio:1.8.0". These are the dependencies I have:
dependencies {
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile files('libs/okio-1.8.0.jar')
compile files('libs/retrofit-2.1.0 (1).jar')
}
As you can see, I have the retrofit and gson libraries simply compile (I'm assuming this downloads them from the internet), I tried doing the same with Okio however it didn't resolve, so I have speicifcally downloaded the 1.8.0 Okio JAR however it still fails to resolve. Why could this be? Any answer would be greatly appreciated. Thank you
Don't put dependencies as a Gradle dependency:
compile 'com.squareup.retrofit2:retrofit:2.1.0'
And as a .jar file in src/libs:
compile files('libs/retrofit-2.1.0 (1).jar')
at one time. Choose only one method. I advise you to choose Gradle dependencies, because they are automatically fetched.
In you case, the dependencies section should look like:
dependencies {
compile `com.google.code.gson:gson:2.7`
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
}
I imported my project from Eclipse to Android Studio. As it is merging all the files, I am getting error : Attribute "background" already defined with incompatible format.Check my below libraries :
compile project(':staggeredGrid')
compile project(':mobikwikSDK')
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
I am new to Android Studio so I don't have any idea about how can I solved this. I tried to change that attribute name but there are many same names so I am unable to go ahead.Please help me to solve this.
ActionBarSherlock is deprecated so migrate to AppCompat
Remove
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
Add
compile 'com.android.support:appcompat-v7:24.1.1'
I have a problem adding the fresco dependency in my project.
Here some screenshots of problem
You have to change
compile 'com.facebook.fresco:fresco:0.8.1+'
with
compile 'com.facebook.fresco:fresco:0.8.1'
The version 0.8.1+ doens't exist.
I suggest you avoiding the use of the + but if you want to use it, you can use one of these:
compile 'com.facebook.fresco:fresco:0.8.1'
compile 'com.facebook.fresco:fresco:0.8.+'
compile 'com.facebook.fresco:fresco:0.+'
compile 'com.facebook.fresco:fresco:+'
I need to use Android's SupportPlaceAutocompleteFragment in a project, but for some reason Android Studio complains that Can not resolve symbol SupportPlaceAutocompleteFragment. Am I missing something in my gradle file:
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
I checked the documentation here but there was mention of which library is required to use this fragment.
SupportPlaceAutocompleteFragment requires Google Play Services 8.4 and you are using Google Play Services 7.5.0
Use :
compile 'com.google.android.gms:play-services:8.4.0'
or
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
Reference : New AutoComplete Widget.
Here is Sample Project for implementing the same.
From what I could gather from a quick look at the documentation, you might be missing the Android Support Library reference in your project. Go to tools->Android->SDK Manager and under extras check if you have the Android Support Library installed, if not install it. Also, add a reference to it in your gradle file like this compile 'com.android.support:support-v4:23.1.1'.