-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: incompatible types: Object cannot be converted to ... #123
Comments
Is there no line number and filename attached to the error
Incompatible types. Required: xxx.Synchronization Found: java.lang.Object
The compiler should print the file and line number where the error happens.
Can you please check that and provide that information?
svedie <[email protected]> schrieb am Sa., 19. Jan. 2019, 22:04:
… Using Kotlin.
I have defined in my root XML data class an element an annotated it with
@element <https://github.com/element>
...
@element
var synchronization: Synchronization?,
...
also I have defined a data class Synchronization
@xml
data class Synchronization(
@Attribute
var type: String?,
@Attribute
var autosync: Int?,
@Attribute
var revision: String?,
@PropertyElement
var url: String?,
@PropertyElement
var download: String?,
@PropertyElement
var upload: String
)
When Android Studio now compiles everything to send it to the device I get
following error:
error: incompatible types: Object cannot be converted to Synchronization
Incompatible types. Required: xxx.Synchronization Found: java.lang.Object
In the TypeAdapter of the main XML file there is following code generated
and it looks like there is no cast to Synchronization object like in a list.
childElementBinders.put("synchronization", new ChildElementBinder<ValueHolder>() {
@OverRide
public void fromXml(XmlReader reader, TikXmlConfig config, ValueHolder value) throws
IOException {
value.synchronization = config.getTypeAdapter(Synchronization.class).fromXml(reader, config);
}
});
For example a list has the needed cast to an account class:
childElementBinders.put("account", new ChildElementBinder<ValueHolder>() {
@OverRide
public void fromXml(XmlReader reader, TikXmlConfig config, ValueHolder value) throws
IOException {
if (value.accounts == null) {
value.accounts = new ArrayList<Account>();
}
value.accounts.add((Account) config.getTypeAdapter(Account.class).fromXml(reader, config) );
}
});
Is this a bug or did I miss something?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#123>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAjnrhYWBOeDr9bnR-dQfFjOZXSfNBk5ks5vE4hYgaJpZM4aJVQD>
.
|
Hi Hannes, the error is on these lines:
There is no other information as
If I scroll down in the generated TypeConverter to the List Element there is a cast on the object:
|
Hm, interesting. You are right that a cast to |
I use Kotlin: implementation 'com.tickaroo.tikxml:annotation:0.8.13' Win10 and Android Studio 3.3. If I edit the generated file and let the Android Studio add the cast, the problem is "solved" (the file will be generated next build, so it is just a temporary change). |
can you please print the output of the following command in windows command line: |
I use Java SDK 1.8.181: javac 1.8.0_181 |
Any news on this issue? |
@svedie
|
Thank you. I will try it. |
Using Kotlin.
I have defined in my root XML data class an element an annotated it with @element
also I have defined a data class Synchronization
When Android Studio now compiles everything to send it to the device I get following error:
error: incompatible types: Object cannot be converted to Synchronization
Incompatible types. Required: xxx.Synchronization Found: java.lang.Object
In the TypeAdapter of the main XML file there is following code generated and it looks like there is no cast to Synchronization object like in a list.
For example a list has the needed cast to an account class:
Is this a bug or did I miss something?
The text was updated successfully, but these errors were encountered: