Closed NightlyNexus closed 5 years ago
Is there no warning emitted? I thought we had done that a while ago (on the phone, so hard to double check)
On Thu, Mar 1, 2018, 12:41 PM Eric Cochran notifications@github.com wrote:
I was adding a @GsonTypeAdapterFactory today and couldn't figure out why my AutoValueGson_JsonAdapterFactory was not being generated.
@GsonTypeAdapterFactorypublic abstract class JsonAdapterFactory implements TypeAdapterFactory { public static TypeAdapterFactory create() { return new AutoValueGson_JsonAdapterFactory(); } }
I later realized that none of my AV models (which are themselves generated by another tool), had included the static jsonAdapter(Gson gson) methods.
Would it be possible to check for @GsonTypeAdapterFactory usage when there is no TypeAdapterFactory to generate? (same question for av-moshi.)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-gson/issues/171, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPJbv2MRD75N0w6gMWcAd-gUx8IO0Q8ks5taHkKgaJpZM4SZHP- .
I ran into this problem today. There is no specific warning emitted from auto-value-gson. The compiler will just complain that the generated class does not exist (cannot find symbol).
I did not realize that I still needed to add the static TypeAdapter methods to every class when using the GsonTypeAdapterFactory until I saw this issue.
Today I got the same error(AutoValueGson_MyAdapterFactory was not generated).
`@GsonTypeAdapterFactory public abstract class MyAdapterFactory implements TypeAdapterFactory {
public static TypeAdapterFactory create() {
return new AutoValueGson_MyAdapterFactory();
}
}
Error log:
Caused by: java.lang.NoClassDefFoundError: com/google/auto/value/AutoValue
at com.ryanharter.auto.value.gson.AutoValueGsonAdapterFactoryProcessor.getSupportedAnnotationTypes(AutoValueGsonAdapterFactoryProcessor.java:61)
....
Caused by: java.lang.ClassNotFoundException: com.google.auto.value.AutoValue
`
java.lang.NoClassDefFoundError: com/google/auto/value/AutoValue same here. Has any one figured out the workaround ?
Hello, I think I may have found a fix for one case. When using multiple, interdependent modules with @AutoValue classes, I was also seeing java.lang.NoClassDefFoundError: com/google/auto/value/AutoValue
Here's what I changed
annotationProcessor 'com.ryanharter.auto.value:auto-value-gson:0.7.0'
annotationProcessor 'com.google.auto.value:auto-value-annotations:1.6' // include again for auto-value-gson
Here was my project dependency structure :app (has autovalues) -> :ui -> :presentation -> :domain (has autovalues). The problem appeared when adding auto-value-gson to :app
Not sure why this is happening! I see that auto-value-gson already includes auto-value-annotations as an API dependency: https://github.com/rharter/auto-value-gson/blob/a264e19063f271f7166ea59b0202f78b854342f1/auto-value-gson/build.gradle#L14
@nksaroj @Andranik-Asilbekyan
@liujoshua (or anyone) know why adding the auto-value-annotations
as annotationProcessor
solve the issue ?
why is this added as an api
dependency for the annotationProcessor?
https://github.com/rharter/auto-value-gson/blob/a264e19063f271f7166ea59b0202f78b854342f1/auto-value-gson/build.gradle#L13
@okmanideep It contains the interfaces ( ex: @interface AutoValue ) to be used by the annotationProcessor.
Not sure but maybe related topic? https://github.com/rharter/auto-value-moshi/issues/106
This also fails when you have the autovalue classes in a different module than your type adapter
I was adding a
@GsonTypeAdapterFactory
today and couldn't figure out why myAutoValueGson_JsonAdapterFactory
was not being generated.I later realized that none of my AV models (which are themselves generated by another tool), had included the static
jsonAdapter(Gson gson)
methods.Would it be possible to check for
@GsonTypeAdapterFactory
usage when there is no TypeAdapterFactory to generate? (same question for av-moshi.)