Attribute "background" already defined with incompatible format in Android Studio - android

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'

Related

Gradle file is edited on creating new Activity/Fragment

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'

Android Studio Weird Warning

After I updated my Support library from 23.1.1 to 23.4.0 I get this warning cannot access android.support.v4.app.baseFragmentActivityEclair on every call to super and every instance of AppCompatActivity
And if I updated my support library to 24.1.1 The warning changes to cannot access android.support.v4.app.baseFragmentActivityJB.
Can anyone tell me why this warning is shown and how can I remove this warning:
here is my dependencies before:
(no error in this)
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
here is my dependencies after cannot access android.support.v4.app.baseFragmentActivityEclairwarning:
compile 'com.android.support:palette-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
here is my dependencies after cannot access android.support.v4.app.baseFragmentActivityJBwarning:
compile 'com.android.support:palette-v7:24.1.1'
compile 'com.android.support:gridlayout-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
We ran into a similar problem when one of the packages in our project had dependencies on version 24.0 support libraries and another package was dependent on version 23.4.0. This seems to be a problem for the Android Studio (IntelliJ) IDE, not the compiler, because we were able to build and run the project without any problems. We resolved the warning by reverting the 24.0 dependency to 23.4.0. I suspect that going the other direction (advancing all of our package dependencies to 24.0) would also have eliminated the warning but we didn't experiment with that due to the number of packages in our project.
If you're looking to hack around this, many of the support libraries have an internal library called libs/internal_impl-$VERSION.jar that includes these types of version-specific implementations. To get your IDE to work, you can extract these JARs and manually include them in your IDE's build path.
For example, you can extract the classes referenced here, assuming version 24.2.1, using this command:
unzip support-fragment-24.2.1.aar libs/internal_impl-24.2.1.jar

Failed to resolve: com.facebook.fresco:fresco:0.8.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:+'

How to import SupportPlaceAutocompleteFragment into an Android Studio project

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'.

Updating play-services gives repeated resources error

I want to use the new Google Cloud Messaging's InstanceID from Google Play Services, and for that I need to update my play-services library.
This is my dependencies from build.dragle from the current version:
dependencies {
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:support-v4:23.1.+'
compile project(':slidingMenuLibrary')
compile 'joda-time:joda-time:2.6'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile files('libs/GraphView-3.1.1.jar')
compile files('libs/ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar')
compile files('libs/libphonenumber-7.0.1.jar')
compile files('libs/opencsv-2.4.jar')
compile files('libs/ormlite-android-4.46.jar')
compile files('libs/ormlite-core-4.46.jar')
compile files('libs/ormlite-jdbc-4.46.jar')
}
And heres is build.dragle from slidingMenuLibrary:
dependencies {
compile 'com.android.support:support-v4:23.1.+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
I updated my Google Play Services on Android SDK Manager to the last version. But when I change compile 'com.google.android.gms:play-services:6.1.+' to compile 'com.google.android.gms:play-services:8.1.0', Android Studio give a list of errors:
Error:(1) Attribute "titleTextStyle" has already been defined
C:\Users\Rui\AndroidStudioProjects\tk-main- repository\tkAndroid\src\main\res\values\colors.xml
Error:(1) Attribute "subtitleTextStyle" has already been defined
Error:(1) Attribute "divider" has already been defined
Error:(1) Attribute "background" has already been defined
Error:(1) Attribute "backgroundSplit" has already been defined
...
When I change back to play-services:6.1.+', all errors disappear.
I know that I have repeated attributes, but I can't understand where can I change them, or what to do to solve this...
any sugestions?
It is no longer recommended to use the full play-services dependency. Rather you should use the individual dependency that you require.
For GCM use:
compile 'com.google.android.gms:play-services-gcm:8.1.0'
See Table 1 in this document for the full list.

Categories

Resources