Giter Club home page Giter Club logo

Comments (16)

ec84b4 avatar ec84b4 commented on July 3, 2024 3

a temporary fix would be to add a dependency to android.jar

apt files('sdkdir/platforms/android-25/android.jar')

from auto-value-gson.

ec84b4 avatar ec84b4 commented on July 3, 2024 1

https://github.com/hister/AutoValueGsonIssue80

this is a simple project demonstrating this issue.

as I understood it this problem happens when a property witch is Parcelable in one of the dependencies

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

This started happening when I upgraded to the newer versions

From:

    autoValueVersion = '1.3-rc2'
    avAnnotationsVersion = '1.2-update1'
    avParcelVersion = '0.2.3-rc2'
    avGsonVersion = '0.4.2'
    avWithVersion = '1.0.0-rc1'

To:

    autoValueVersion = '1.3'
    avAnnotationsVersion = '1.3'
    avParcelVersion = '0.2.5'
    avGsonVersion = '0.4.3'
    avWithVersion = '1.0.0-rc1'

from auto-value-gson.

rharter avatar rharter commented on July 3, 2024

Can you look in the build directory to see what's actually being generated? You should be able to find it in build/generated/source/apt.

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

I see that out of all the @autovalue classes, only a handful have their implementations generated.

Not sure if this is comprehensible. Let me know if more details are needed.

from auto-value-gson.

rharter avatar rharter commented on July 3, 2024

If the processor fails at some point, that might be expected. We need to find the source of the android/os/Parcelable. Since the error is Caused by: java.lang.ClassNotFoundException: android.os.Parcelable, I'm expecting that the source is formatted correctly. Can you please check the generated source files to verify?

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

There are only 3 AutoValue classes whose sources have been generated.
And here's the interesting part: One could only generate a $$AutoValue_Name (auto-value) and didn't proceed further. $AutoValue_Name should have been generated by the gson extension and AutoValue_Name by the parcel extension.

AutoValue class:

package com.example;

import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.example.data.User;

@AutoValue
public abstract class Request implements Parcelable {

    public static Request create(@NonNull User user, @Nullable String description) {
        return new AutoValue_Request(user, description);
    }

    public static TypeAdapter<Request> typeAdapter(Gson gson) {
        return new AutoValue_Request.GsonTypeAdapter(gson);
    }

    @NonNull
    public abstract User user();

    @Nullable
    public abstract String description();
}

auto-value generated: $$AutoValue_Request

package com.example;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.example.data.User;

 abstract class $$AutoValue_Request extends Request {

  private final User user;
  private final String description;

  $$AutoValue_Request(
      User user,
      @Nullable String description) {
    if (user == null) {
      throw new NullPointerException("Null user");
    }
    this.user = user;
    this.description = description;
  }

  @NonNull
  @Override
  public User user() {
    return user;
  }

  @Nullable
  @Override
  public String description() {
    return description;
  }

  @Override
  public String toString() {
    return "Request{"
        + "user=" + user + ", "
        + "description=" + description
        + "}";
  }

  @Override
  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (o instanceof Request) {
      Request that = (Request) o;
      return (this.user.equals(that.user()))
           && ((this.description == null) ? (that.description() == null) : this.description.equals(that.description()));
    }
    return false;
  }

  @Override
  public int hashCode() {
    int h = 1;
    h *= 1000003;
    h ^= this.user.hashCode();
    h *= 1000003;
    h ^= (description == null) ? 0 : this.description.hashCode();
    return h;
  }

}

auto-value-gson: $AutoValue_Request

None

auto-value-parcel: AutoValue_Request

None

Note: User class is also an AutoValue and a Parcelable.

from auto-value-gson.

rharter avatar rharter commented on July 3, 2024

This is an Android module, right? As opposed to a java only module?

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

That's correct.

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

@rharter Did this information help you get anywhere?

from auto-value-gson.

rharter avatar rharter commented on July 3, 2024

I haven't been able to repro this one. Can you make a simple project demonstrating this issue, please?

from auto-value-gson.

muddin1 avatar muddin1 commented on July 3, 2024

@Hister Thanks a lot for posting the example project.
Using your solution for now.

@rharter This project produces the exact error I am having. Hope it is useful in debugging.

from auto-value-gson.

ec84b4 avatar ec84b4 commented on July 3, 2024

@rharter could you take a look at this ?

from auto-value-gson.

Piasy avatar Piasy commented on July 3, 2024

I have the same issue, and @Hister 's workaround works.

from auto-value-gson.

ZacSweers avatar ZacSweers commented on July 3, 2024

Per talking with the android tools team, a future version of the android gradle plugin's annotationProcessor configuration will have the android jar on the classpath, so this will just have to wait until then.

Ref: https://code.google.com/p/android/issues/detail?id=231914

from auto-value-gson.

gengjiawen avatar gengjiawen commented on July 3, 2024

If you prefer simple export, you can use this

apt files("$android.sdkDirectory.path/platforms/android-26/android.jar")

from auto-value-gson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.