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

AIDL: CREATOR cannot be resolved or is not a field #91

Open
autonomousapps opened this Issue Oct 2, 2016 · 13 comments

Comments

Projects
None yet
4 participants
@autonomousapps

autonomousapps commented Oct 2, 2016

I'm attempting to use this extension because I want to pass an AutoValue-annotated class across a process boundary with AIDL. Project here, specific commit demonstrating issue here.

It's possible I'm simply not using something correctly.

When I run ./gradlew assembleDebug, I get the following error:

ERROR: /workspace/ReactiveStopwatch/app/build/generated/source/aidl/debug/com/autonomousapps/reactivestopwatch/service/IStopwatchService.java:172: CREATOR cannot be resolved or is not a field

The generated IStopwatchService.java class has this line:

_result = com.autonomousapps.reactivestopwatch.time.Lap.CREATOR.createFromParcel(_reply);

Which might be the problem. After all, Lap doesn't have that field. AutoValue_Lap, however, does. I could change all my implementations to use the latter instead of the former, but that seems to be against the spirit of the thing.

Here's my AutoValue-annotated class:

package com.autonomousapps.reactivestopwatch.time;

@AutoValue
public abstract class Lap implements Parcelable {

    public static Lap create(long duration, long endTime) {
        return new AutoValue_Lap(duration, endTime);
    }

    abstract long duration();

    abstract long endTime();
}

AIDL definition:

package com.autonomousapps.reactivestopwatch.time;

parcelable Lap;

Use in other AIDL file:

package com.autonomousapps.reactivestopwatch.service;

import com.autonomousapps.reactivestopwatch.time.Lap;

interface IStopwatchService {
    // other methods omitted
    Lap lap();
}
@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Oct 2, 2016

Owner

If you want to call the CREATOR directly you are correct, you would have to use the implementation, as opposed to the abstract class. You are also correct that that is kind of against the spirit of how it's intended to be used (exposing implementation detail).

I think normally you would use the Parcel's getParcelable and putParcelable methods, and it will resolve the types automatically and return the (subclass implementation of) your Lap class.

Owner

rharter commented Oct 2, 2016

If you want to call the CREATOR directly you are correct, you would have to use the implementation, as opposed to the abstract class. You are also correct that that is kind of against the spirit of how it's intended to be used (exposing implementation detail).

I think normally you would use the Parcel's getParcelable and putParcelable methods, and it will resolve the types automatically and return the (subclass implementation of) your Lap class.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps Oct 2, 2016

Unfortunately, IStopwatchService.java is auto-generated from its AIDL file, and I don't know if how it does that is configurable.

I'm not really sure what you mean about getParcelable and putParcelable. Like I said, I'm relying on the build system to generate these files, and I'm actually doing nothing with the parceling myself (at least not directly).

Is there some way I could declare the CREATOR field in the abstract class, but let its implementation be taken care of by the subclass? Not even sure if that would work... perhaps AIDL just doesn't play nicely with this use case?

autonomousapps commented Oct 2, 2016

Unfortunately, IStopwatchService.java is auto-generated from its AIDL file, and I don't know if how it does that is configurable.

I'm not really sure what you mean about getParcelable and putParcelable. Like I said, I'm relying on the build system to generate these files, and I'm actually doing nothing with the parceling myself (at least not directly).

Is there some way I could declare the CREATOR field in the abstract class, but let its implementation be taken care of by the subclass? Not even sure if that would work... perhaps AIDL just doesn't play nicely with this use case?

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Oct 2, 2016

Collaborator

You could probably put

public static final Creator CREATOR = AutoValue_Lap.CREATOR;

in Lap and have it work as well.

On Sun, Oct 2, 2016 at 7:49 AM Tony Robalik notifications@github.com
wrote:

I'm attempting to use this extension because I want to pass an
AutoValue-annotated class across a process boundary with AIDL. Project
here https://bitbucket.org/tonyrobalik/reactivestopwatch, specific
commit demonstrating issue here
https://bitbucket.org/tonyrobalik/reactivestopwatch/commits/8dacdd5dd9c928ffd146ef5889e8bf7d590fcc8d
.

It's possible I'm simply not using something correctly.

When I run ./gradlew assembleDebug, I get the following error:

ERROR: /workspace/ReactiveStopwatch/app/build/generated/source/aidl/debug/com/autonomousapps/reactivestopwatch/service/IStopwatchService.java:172: CREATOR cannot be resolved or is not a field

The generated IStopwatchService.java class has this line:

_result = com.autonomousapps.reactivestopwatch.time.Lap.CREATOR.createFromParcel(_reply);

Which might be the problem. After all, Lap doesn't have that field.
AutoValue_Lap, however, does. I could change all my implementations to
use the latter instead of the former, but that seems to be against the
spirit of the thing.

Here's my AutoValue-annotated class:

package com.autonomousapps.reactivestopwatch.time;
@AutoValuepublic abstract class Lap implements Parcelable {

public static Lap create(long duration, long endTime) {
    return new AutoValue_Lap(duration, endTime);
}

abstract long duration();

abstract long endTime();

}

AIDL definition:

package com.autonomousapps.reactivestopwatch.time;

parcelable Lap;

Use in other AIDL file:

package com.autonomousapps.reactivestopwatch.service;
import com.autonomousapps.reactivestopwatch.time.Lap;
interface IStopwatchService {
// other methods omitted
Lap lap();
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#91, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAEEEVoCLbCp2wzs93PR4WDjjsP7iq6Lks5qv0XkgaJpZM4KL8Qf
.

Collaborator

JakeWharton commented Oct 2, 2016

You could probably put

public static final Creator CREATOR = AutoValue_Lap.CREATOR;

in Lap and have it work as well.

On Sun, Oct 2, 2016 at 7:49 AM Tony Robalik notifications@github.com
wrote:

I'm attempting to use this extension because I want to pass an
AutoValue-annotated class across a process boundary with AIDL. Project
here https://bitbucket.org/tonyrobalik/reactivestopwatch, specific
commit demonstrating issue here
https://bitbucket.org/tonyrobalik/reactivestopwatch/commits/8dacdd5dd9c928ffd146ef5889e8bf7d590fcc8d
.

It's possible I'm simply not using something correctly.

When I run ./gradlew assembleDebug, I get the following error:

ERROR: /workspace/ReactiveStopwatch/app/build/generated/source/aidl/debug/com/autonomousapps/reactivestopwatch/service/IStopwatchService.java:172: CREATOR cannot be resolved or is not a field

The generated IStopwatchService.java class has this line:

_result = com.autonomousapps.reactivestopwatch.time.Lap.CREATOR.createFromParcel(_reply);

Which might be the problem. After all, Lap doesn't have that field.
AutoValue_Lap, however, does. I could change all my implementations to
use the latter instead of the former, but that seems to be against the
spirit of the thing.

Here's my AutoValue-annotated class:

package com.autonomousapps.reactivestopwatch.time;
@AutoValuepublic abstract class Lap implements Parcelable {

public static Lap create(long duration, long endTime) {
    return new AutoValue_Lap(duration, endTime);
}

abstract long duration();

abstract long endTime();

}

AIDL definition:

package com.autonomousapps.reactivestopwatch.time;

parcelable Lap;

Use in other AIDL file:

package com.autonomousapps.reactivestopwatch.service;
import com.autonomousapps.reactivestopwatch.time.Lap;
interface IStopwatchService {
// other methods omitted
Lap lap();
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#91, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAEEEVoCLbCp2wzs93PR4WDjjsP7iq6Lks5qv0XkgaJpZM4KL8Qf
.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps Oct 2, 2016

Just tried, here's the error message:

ERROR: /workspace/ReactiveStopwatch/app/src/main/java/com/autonomousapps/reactivestopwatch/time/Lap.java:19: Manual implementation of a static Parcelable.Creator<T> CREATOR field found when processing com.autonomousapps.reactivestopwatch.time.Lap. Remove this so auto-value-parcel can automatically generate the implementation for you.

Android Studio is also complaining that it's an incompatible assignment (screen cap).

I tried replacing the declaration like so:

public static final Creator<AutoValue_Lap> CREATOR = AutoValue_Lap.CREATOR;

but then it failed with this error:

* What went wrong:
Execution failed for task ':app:transformJackWithJackForDebug'.
> com.android.jack.ir.JNodeInternalError: Error building Jack IR: com.android.jack.eclipse.jdt.internal.compiler.ast.TypeDeclaration at "/workspace/ReactiveStopwatch/app/build/generated/source/apt/debug/com/autonomousapps/reactivestopwatch/ui/StopwatchFragment_ViewBinding.java:15.14-15.42"

autonomousapps commented Oct 2, 2016

Just tried, here's the error message:

ERROR: /workspace/ReactiveStopwatch/app/src/main/java/com/autonomousapps/reactivestopwatch/time/Lap.java:19: Manual implementation of a static Parcelable.Creator<T> CREATOR field found when processing com.autonomousapps.reactivestopwatch.time.Lap. Remove this so auto-value-parcel can automatically generate the implementation for you.

Android Studio is also complaining that it's an incompatible assignment (screen cap).

I tried replacing the declaration like so:

public static final Creator<AutoValue_Lap> CREATOR = AutoValue_Lap.CREATOR;

but then it failed with this error:

* What went wrong:
Execution failed for task ':app:transformJackWithJackForDebug'.
> com.android.jack.ir.JNodeInternalError: Error building Jack IR: com.android.jack.eclipse.jdt.internal.compiler.ast.TypeDeclaration at "/workspace/ReactiveStopwatch/app/build/generated/source/apt/debug/com/autonomousapps/reactivestopwatch/ui/StopwatchFragment_ViewBinding.java:15.14-15.42"
@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps commented Oct 2, 2016

If it's helpful, Gradle build scan: https://scans.gradle.com/s/pw6wdwaifuce2

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Oct 2, 2016

Collaborator

Ah, yeah we forbid you from trying to define your own creator.

On Sun, Oct 2, 2016, 5:52 PM Tony Robalik notifications@github.com wrote:

Just tried, here's the error message:

ERROR: /workspace/ReactiveStopwatch/app/src/main/java/com/autonomousapps/reactivestopwatch/time/Lap.java:19: Manual implementation of a static Parcelable.Creator CREATOR field found when processing com.autonomousapps.reactivestopwatch.time.Lap. Remove this so auto-value-parcel can automatically generate the implementation for you.

Android Studio is also complaining that it's an incompatible assignment screen
cap
https://www.dropbox.com/s/l7x8tnj6j0y7to5/Screen%20Shot%202016-10-02%20at%2010.48.27%20AM.png?dl=0
.

I tried replacing the declaration like so:

public static final Creator<AutoValue_Lap> CREATOR = AutoValue_Lap.CREATOR;

but then it failed with this error:

  • What went wrong:
    Execution failed for task ':app:transformJackWithJackForDebug'.

    com.android.jack.ir.JNodeInternalError: Error building Jack IR: com.android.jack.eclipse.jdt.internal.compiler.ast.TypeDeclaration at "/workspace/ReactiveStopwatch/app/build/generated/source/apt/debug/com/autonomousapps/reactivestopwatch/ui/StopwatchFragment_ViewBinding.java:15.14-15.42"


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#91 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYs-9llEwYl6Hq9vQX7oo5ktBIyAks5qv9NRgaJpZM4KL8Qf
.

Collaborator

JakeWharton commented Oct 2, 2016

Ah, yeah we forbid you from trying to define your own creator.

On Sun, Oct 2, 2016, 5:52 PM Tony Robalik notifications@github.com wrote:

Just tried, here's the error message:

ERROR: /workspace/ReactiveStopwatch/app/src/main/java/com/autonomousapps/reactivestopwatch/time/Lap.java:19: Manual implementation of a static Parcelable.Creator CREATOR field found when processing com.autonomousapps.reactivestopwatch.time.Lap. Remove this so auto-value-parcel can automatically generate the implementation for you.

Android Studio is also complaining that it's an incompatible assignment screen
cap
https://www.dropbox.com/s/l7x8tnj6j0y7to5/Screen%20Shot%202016-10-02%20at%2010.48.27%20AM.png?dl=0
.

I tried replacing the declaration like so:

public static final Creator<AutoValue_Lap> CREATOR = AutoValue_Lap.CREATOR;

but then it failed with this error:

  • What went wrong:
    Execution failed for task ':app:transformJackWithJackForDebug'.

    com.android.jack.ir.JNodeInternalError: Error building Jack IR: com.android.jack.eclipse.jdt.internal.compiler.ast.TypeDeclaration at "/workspace/ReactiveStopwatch/app/build/generated/source/apt/debug/com/autonomousapps/reactivestopwatch/ui/StopwatchFragment_ViewBinding.java:15.14-15.42"


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#91 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYs-9llEwYl6Hq9vQX7oo5ktBIyAks5qv9NRgaJpZM4KL8Qf
.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps Oct 2, 2016

Yeah, I thought so (from a cursory review of other issues). Is that a restriction we can loosen?

autonomousapps commented Oct 2, 2016

Yeah, I thought so (from a cursory review of other issues). Is that a restriction we can loosen?

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Oct 2, 2016

Collaborator

We could enable the use of @SuppressWarning to skip it.

On Sun, Oct 2, 2016, 6:58 PM Tony Robalik notifications@github.com wrote:

Yeah, I thought so (from a cursory review of other issues). Is that a
restriction we can loosen?


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#91 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEanwmMFolKKQmaAC-EFkLt5VWwrEks5qv-LOgaJpZM4KL8Qf
.

Collaborator

JakeWharton commented Oct 2, 2016

We could enable the use of @SuppressWarning to skip it.

On Sun, Oct 2, 2016, 6:58 PM Tony Robalik notifications@github.com wrote:

Yeah, I thought so (from a cursory review of other issues). Is that a
restriction we can loosen?


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#91 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEanwmMFolKKQmaAC-EFkLt5VWwrEks5qv-LOgaJpZM4KL8Qf
.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps Oct 2, 2016

I'd be willing to test an experimental branch or binary.

autonomousapps commented Oct 2, 2016

I'd be willing to test an experimental branch or binary.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@autonomousapps

autonomousapps Oct 2, 2016

I can also take a stab at a PR for the issue.

autonomousapps commented Oct 2, 2016

I can also take a stab at a PR for the issue.

@autonomousapps

This comment has been minimized.

Show comment
Hide comment
@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Oct 5, 2016

Owner

I've filed this bug with the tools team.

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

Owner

rharter commented Oct 5, 2016

I've filed this bug with the tools team.

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

@atrich-ms

This comment has been minimized.

Show comment
Hide comment
@atrich-ms

atrich-ms Jan 23, 2018

Is there no action on this? Any workarounds? I'm having to port a codebase with a lot of autovalue types into an android service, and this issue is preventing me from making my types parcelable.

I attempted to use the AutoValue_ version of the type, but that type is defined as internal to the package it's declared in.

atrich-ms commented Jan 23, 2018

Is there no action on this? Any workarounds? I'm having to port a codebase with a lot of autovalue types into an android service, and this issue is preventing me from making my types parcelable.

I attempted to use the AutoValue_ version of the type, but that type is defined as internal to the package it's declared in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment