I checked the question : setGroup() is undefined for the type NotificationCompat.Builder?
But it did not help.
I have a project which I imported from eclipse. On running I get error:
error: cannot find symbol .setGroup("group") ^ symbol: method setGroup(String)
On googling I find people suggesting to update android-support library.While importing the project I used the option to retain the jar files from the project and not convert them to dependencies in android studio.Hence I presume the same support jar file is being used from the libs folder of project. The same code runs fine on eclipse. On checking I see the support jar file is exactly same on both projects. Then how come one method is being undefined in project but visible on another. Is it possible that Android Studio is replacing the support jar file from its own jar file?
Code:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(text)
.setContentText(text)
.setStyle(inboxStyle)
.setNumber(stack.size())
.setSmallIcon(R.drawable.launcher)
.setGroup("group")
.setGroupSummary(true);
EDIT:
I changed the dependency as per below suggestion to use dynamic support library instead of jar. But still see the same error, My build.gradle looks like this now.
compile project(':facebookSDK')
compile project(':googleplayservices_lib')
compile 'com.android.support:support-v13:25.1.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
// compile files('libs/android-support-v13.jar')
compile files('libs/eat.jar')
compile files('libs/gcm-server-1.0.2.jar')
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-api-client-android2-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-http-client-android2-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-beta.jar')
compile files('libs/gson-2.1.jar')
compile files('libs/jackson-core-asl-1.9.4.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/mail.jar')
EDIT2:
Based on below answer I added v4 library alongside v13 but still the error persists. Any more clues? My current dependencies look like
dependencies {
compile project(':facebookSDK')
compile project(':googleplayservices_lib')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-support-v13.jar')
compile 'com.android.support:support-v4:25.1.0'
compile files('libs/eat.jar')
compile files('libs/gcm-server-1.0.2.jar')
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-api-client-android2-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-http-client-android2-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-beta.jar')
compile files('libs/gson-2.1.jar')
compile files('libs/jackson-core-asl-1.9.4.jar')
compile files('libs/json-simple-1.1.1.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/mail.jar')
}
edit4:
I also tried this combination, nothing seems to be working :(
// compile files('libs/android-support-v13.jar')
compile 'com.android.support:support-v13:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
I also noticed one thing, even if I remove v4 from dependencies , I dont get a compilation error while import NotificationCompat classes. How come this be possible? Could it be that it is picking up some other copy of library from some other module?
EDIT: 5
Based on my discussions here with Martin I wanted to share some insights which would help us all . As per Android Studio it picks up the first library (or any library, I am not sure) from any modules and starts using it in your module. This is wrong at so many levels! I will explain you how, Please correct me at any place as this would help us all.
Causes licensing issue: As in here , I am using a vendor library module in project (Facebbok SDK in this case) , it is using some libraries for its own purpose (v4 lib in this case). Now as a developer I do not know what are the licensing terms in which my vendor library is using that third party library. But never the less I am able to use the same library in my module, EVEN WHEN I HAVE NOT DEFINED IT IN MY OWN DEPENDENCIES, breaching licensing agreement.
Causes confusion: Imagine this, I am not even aware that I am using a function from a third party library. As I see that I have not defined this library my build.gradle. But internally I might have used a function which had come up from a random library. The editor will of course silent import the classes for that method and the developer will not have any clue as to which library it called. This is exactly what happened here , as I was not aware that this method was coming from a v4 library as I had not imported it in my build.gradle file!
Unable to update to latest version: This is yet another problem that I faced here. After the below discussion I am aware that AS has used facebooks library, but now I am unable to update the library for my use. Why? because facebook has used the old library
at the time of developement. I cannot update facebook's library (technically I can but I should not ) and I dont want to update faceboook sdk due to some other constraints. Also, no reason to update facbook sdk as all my current needs are being fulfilled from this sdk.
All this just because AS thinks it knows better than me as to which library I should be using in my own project.