1

I use iText 5 in Android Studio to create a PDF document but I get an error:

enter image description here

I also tried

p.add((Phrase)c);

but I get same error :-(

How I can get rid of this error?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
mr.burns
  • 493
  • 2
  • 6
  • 14
  • 2
    Is Phrase a sub-class of ArrayList? What does the `add` method look like? – Eran Mar 23 '17 at 08:48
  • 1
    try to this link http://stackoverflow.com/questions/20255420/what-is-an-ambiguous-type-error-in-java – Dileep Patel Mar 23 '17 at 08:49
  • Place there the minimized copy of your code (from which you remove EVERYTHING which is NOT needed to produce your error), including the `import` commands. – Honza Zidek Mar 23 '17 at 13:36
  • 2
    Try `((Phrase) p).add(c)`. If it works, I will put it as an answer :) now I just have a certain suspicion. – Honza Zidek Mar 23 '17 at 13:41
  • I stand corrected. In any case we need to see more of the code, and NOT as a screenshot but as actual code that anyone can copy/paste into their ID. – Amedee Van Gasse Mar 23 '17 at 14:11
  • @DileepPatel: it is not the same case! Here he has "ambiguous **method call**" (the compiler cannot decide which **method** to use), whilst your linked question has "ambiguous **type**" (the compiler cannot decide which **type** to use: java.util.List vs. java.awt.List). – Honza Zidek Mar 23 '17 at 14:21

3 Answers3

2

In case when we use data binding, some java files are auto-generated
The problem was occured when a getter/setter has the same name with a function. eg

  • var newData
  • fun getNewData()

in this case, in the generated java file, the variable's getter has the same name with the function => getNewData.

So simply you have to change variable name or fuction name

0

"ambiguous" error comes up when u already have a file/varibale etc with same name. for example when you make a project using entity framework , entity framework make class and dbcontext files for u. but if u add a class with same name as entity framework had made for u then this error comes up. check ur project/programe correctly and fully again... Hope its helpfull !!

and checkout this link for ur answer Android Studio - Ambiguous method call getClass()

Community
  • 1
  • 1
Rahul Puri
  • 11
  • 3
  • I believe the OP does understand *what* the ambiguous type error is. He is asking *why* he has it in *this specific case*. – Honza Zidek Mar 23 '17 at 13:38
  • that is why i have given the link related to error because its is already answered by some1 earlier @HonzaZidek – Rahul Puri Mar 24 '17 at 05:49
  • But your explanation of the *ambiguous type* error does not belong here. It is completely confusing in the OP's particular context. The OP's problem most probably is **not** the class/variable with the same name! – Honza Zidek Mar 24 '17 at 10:04
0

thanks for reply - indeed I needed help regarding why 'ambiguous' appears in this context. But now the problem is solved - this error does not appear anymore - but I don't know exactly why. I did some Android Studio updates last week may this helped?

Thanks anyway!

mr.burns
  • 493
  • 2
  • 6
  • 14