frankiesardo / auto-parcel Goto Github PK
View Code? Open in Web Editor NEWAndroid Parcelable models made easy
License: Eclipse Public License 1.0
Android Parcelable models made easy
License: Eclipse Public License 1.0
Could you add support for provided scope?
To be able use library with
provided 'com.github.frankiesardo:auto-parcel-processor:+'
instead of having extra dependency from apt and usage
apt 'com.github.frankiesardo:auto-parcel-processor:+'
With current version, usage of provided scope stops code generation.
Environment: Android Studio 0.8.8.
Hi!
It is possible to ignore a field in equals / hascode validation? I didn't find any annotation or configuration for this case.
AutoValue strips JavaBeans prefixes (get-, is-) from constructor parameter names if the annotated class uses it consistently (see AutoValue HowTo). AutoParcel ignores this and uses the full property name in the generated constructor.
It would be nice if AutoParcel would use the same naming for it's constructor parameter names.
Sample
User.java
package com.example;
import android.os.Parcelable;
import com.google.auto.value.AutoValue;
@AutoValue
public abstract class User implements Parcelable {
public abstract String getId();
public abstract String getName();
}
$AutoValue_User.java (generated by AutoValue)
package com.example;
import javax.annotation.Generated;
@Generated("com.google.auto.value.processor.AutoValueProcessor")
abstract class $AutoValue_User extends User {
private final String id;
private final String name;
$AutoValue_User(
String id,
String name) {
if (id == null) {
throw new NullPointerException("Null id");
}
this.id = id;
if (name == null) {
throw new NullPointerException("Null name");
}
this.name = name;
}
@Override
public String getId() {
return id;
}
@Override
public String getName() {
return name;
}
...
}
AutoValue_User.java (generated by AutoParcel)
package com.example;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.ClassLoader;
final class AutoValue_User extends $AutoValue_User {
private final static ClassLoader CL = AutoValue_User.class.getClassLoader();
public AutoValue_User (
java.lang.String getId,
java.lang.String getName
) {
super(
getId,
getName
);
}
...
}
Could you annotate your model classes with AutoValue
when using with Gson? Since Gson uses fields directly, I wasn't sure how it would work.
javabeans must be abstract?
if use auto-parcel
I declared a class that has a String array property.
@AutoParcel
public abstract class Foo implements Parcelable {
abstract String[] bar();
}
However, the compiler throws:
An @AutoParcel class cannot define an array-valued property unless it is a primitive array
Is there any reason to not have support for String arrays?
A warning is logged during build whenever I create an AutoParcel-class that implements Parcelable
: warning: @AutoParcel classes cannot have abstract methods other than property getters and Builder converters
Example class:
@AutoParcel
public abstract class TestAutoP implements Parcelable {
public abstract String name();
public static TestAutoP create(String name) {
return new AutoParcel_TestAutoP(name);
}
}
without Parcelable
, the warning isn't logged.
Tested with Gradle 2.4, Java 1.8.0_40-ea, starting the build from the commandline.
Otherwise, the so called 'immutable' object is actually mutable.
Such as the object contains a List, it can modify the items in the List by both using the reference used to build the object, and using the reference get from the accessor.
The generated constructor does not keep annotations from the original constructor.
This causes problems with inspections, checking if a @nullable argument is passed to non-annotated parameters.
The latest gradle plugins start deprecating apt in favor of annotationProcessor
configuration scope for the android gradle plugin to support the jack and jill compiler. You can test it with classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
When the current annotation processor is used, I get the following error:
Gradle 'myProject' project refresh failed
Error:Cannot change dependencies of configuration ':demo:_debugAnnotationProcessor' after it has been resolved.
Here I paste my gradle config:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "my.mock.package"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
useJack true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.1.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
//Autovalue
annotationProcessor 'com.google.auto.value:auto-value:1.3-rc2'
provided 'com.google.auto.value:auto-value:1.3-rc2'
annotationProcessor 'frankiesardo:auto-parcel:1.0.3'
}
I tried to use this library in an app that uses Dagger and Gradle.
I get the following error "java.lang.IllegalStateException: Module adapter for class com.mypackage.ApiModule Please ensure that code generation was run for this module".
Code generation appears to stall when this lib is set up. When I remove android-auto-value code generation returns to normal.
Hi. i want to use auto-parecel alongside simple-stack for this task. When i add this library and sync the gradle everything is ok, but when i build the project this error appear:
> Error:Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.
> > Could not resolve frankiesardo:auto-parcel:1.0.3.
> Required by:
> project :app
> > Could not resolve frankiesardo:auto-parcel:1.0.3.
> > Could not get resource 'https://clojars.org/repo/frankiesardo/auto-parcel/1.0.3/auto-parcel-1.0.3.pom'.
> > Could not GET 'https://clojars.org/repo/frankiesardo/auto-parcel/1.0.3/auto-parcel-1.0.3.pom'. Received status code 403 from server: Request blocked by Privoxy
I follow the instructions in this page for install auto-parcel.
And this is my gradle-properties:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8123
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8123
systemProp.socks.proxyHost=127.0.0.1
systemProp.socks.proxyPort=9050
The latest AutoValue adds support for builders and value validation. Two things which would make complex parcelables much easier to work with.
Square might be able to do this work in the next few weeks if you do not have the time.
We occasionally forget to include implements Parcelable
on our declarations which ends up failing at runtime. The processor should enforce that all classes annotated with @AutoParcel
indeed include this declaration (either directly or from a base class) thus moving this to a compile-time validation.
I believe you can look at how @AutoService
does verification and copy/paste most or all of its logic.
Android AIDL processor seems to be very peculiar about naming and stuff:
// Task.aidl
package net.sf.fakenames.smartinflater;
parcelable AutoParcel_Task;
does not work: AIDL compiler complains, that AutoParcel_Task should be declared in appropriately named file.
I see 2 solutions:
Or, perhaps.. I am just missing something?
I love this library (and appreciate your effort)!
When I started using this library, I realize one thing that the objects this library creates might not be truly immutable, which violates the purpose of this library or AutoValue.
This is generated code from one of my classes:
private AutoParcel_SpotifyPaging(android.os.Parcel in) {
this((ImmutableList<T>) in.readValue(CL), (Integer) in.readValue(CL), (Integer) in.readValue(CL), (Integer) in.readValue(CL), (String) in.readValue(CL), (String) in.readValue(CL));
}
which of course crashes when it tries to type cast an ArrayList to an ImmutableList. (In Android the list is always going to be an ArrayList after reading from Parcel and it will be mutable)
However if I change the type of list to List, then the generated code will just take in a List and return it.
Constructor:
if (items == null) {
throw new NullPointerException("Null items");
}
this.items = items;
Getter:
@Override
public List<T> items() {
return items;
}
The returned list now becomes mutable.
So is there a way to override the current behavior?
For example to allow getters return ImmutableList but setters in builder take in a generic List. Or allow us to write a concrete setter in builder that won't be extended?
AutoValue itself handles generics properly:
Generated("com.google.auto.value.processor.AutoValueProcessor")
abstract class $AutoValue_Action<T extends Parcelable> extends Action<T> {
But auto-parcel
fails:
final class AutoValue_Action extends $AutoValue_Action {
In 1.0.3, I get raw type
public AutoValue_Action (
java.lang.String type,
T payload
@autovalue with Parcelable interface can't be used for class, which implements all of the abstract methods. Example of use can be Null object in fail-fast approach - a following exception is being thrown on compilation process:
@AutoValue processor threw an exception: java.lang.IndexOutOfBoundsException
Here is an example:
public interface Person {
String id();
String firstname();
String lastname();
boolean isProvided();
@AutoValue
abstract class Empty implements Person, Parcelable {
public static Empty create() {
return new AutoValue_Person_Empty();
}
@Override
public String id() {
throw new UnsupportedOperationException(
"there is nothing here"
);
}
@Override
public String firstname() {
throw new UnsupportedOperationException(
"there is nothing here"
);
}
@Override
public String lastname() {
throw new UnsupportedOperationException(
"there is nothing here"
);
}
@Override
public boolean isProvided() {
return false;
}
}
}
Since I upgraded to auto-parcel-0.3 my release build fails with these warnings from proguard:
Warning: library class auto.parcel.processor.SimpleNameFunction extends
or implements program class com.google.common.base.Function
Warning: library class auto.parcel.processor.TypeSimplifier$1$1 extends
or implements program class com.google.common.base.Predicate
Warning: library class com.google.auto.common.MoreTypes$1 extends
or implements program class com.google.common.base.Equivalence
Warning: there were 3 instances of library classes depending on program classes.
You must avoid such dependencies, since the program classes will
be processed, while the library classes will remain unchanged.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
These are probably related lines from my build.gradle:
compile 'com.google.guava:guava:18.0'
compile 'com.github.frankiesardo:auto-parcel:0.3'
provided 'com.github.frankiesardo:auto-parcel-processor:0.3'
I am not sure whether this is an issue in auto-parcel, but since I did not have it with 0.2 version I decided to report.
Congrats to the 1.0 release.
Not really an issue, but what is the difference to auto-value-parcel? Is there something one can that the others can't?
The name "Android AutoValue" implies that AutoValue somehow doesn't work on Android which is of course not true. Additionally, when using both this and the original, it's needlessly ambiguous which is in use where. Additionally, using the package of android.*
is a bit of an anti-pattern since it conveys you are authoring code on behalf of the platform (and therefore Google).
I would recommend you change the annotation to @AutoParcel
to better convey the behavior and change the package to auto.parcel
to line-up with the other Auto offerings.
Creating a parcel-variant of AutoValue was one of the first things I did when it came out. My version, however, tears out the weird custom string template and removes the Eclipse compiler workaround. It uses @AutoParcel
as the annotation and the auto.parcel
package. I have a library I want to release which relies on callers creating a few parcelable things. I want to offer a library like this one to make it easy but I am fundamentally against the two things outlined in the first paragraph. I would prefer if you made changes to accommodate these, but it's your library to do with what you want and are of course welcome to say no.
Seems like auto parcel doens't play well with android annotations. After i added auto-parcel, android annotations stopped generating classes. Any idea?
When I declare an object value and annotate it with android.support.annotation.NonNull
annotation, there is a null-check generated but the overriding method is not annotated and IDE shows appropriate warning.
MyObject.java:
AutoParcel_MyObject.java:
Is it possible to use same annotation on overriding getters as for declared values?
I couldn't find a way to exclude some fields in the generation of equals() and hashCode() methods but I believe this could be very useful. In my case I had to revert back to using Pojos so I can have control over implementing equals/hashCode. What is your opinion about supporting such functionality?
Autovalue 1.3 has changed the way extensions work breaking auto-parcel.
I get the following error:
Error:(15, 17) error: Extension auto_parcel.AutoParcelExtension wants to consume a property that does not exist: writeToParcel
new IllegalStateException("Missing required properties:" + missing is thrown if I don't call all Builder methods. Why do you have such behavior there? Sometimes developer may need to call :
AutoParcel_SomeObject.Builder().build(); and now IllegalStateException will be thrown in this case.
Seems like @nullable annotation solves that problem but that a bad practice to use that annotation near primitive types.
Im getting this warning on Android studio 3.1.4 any solutions?
Is there a reason why you don't allow property setters? Would be a nice to have, if there is no reason to disallow them...
It is not pussible(but sometimes very useful) to have empty parcelable class like this:
@AutoValue
public abstract class MyAutoValue implements Parcelable {
public static MyAutoValue create() { return new AutoValue_MyAutoValue(); }
}
Now I use workaround, but but it would be very nice to avoid this:
@AutoValue
public abstract class MyAutoValue implements Parcelable {
abstract int noValue();
public static MyAutoValue create() { return new AutoValue_MyAutoValue(0); }
}
Pure, empty AutoValue classes work correctly without "implements Parcelable" declaration.
Error:(8, 17) error: @AutoValue processor threw an exception: java.lang.IndexOutOfBoundsException
at clojure.lang.PersistentVector.assocN(PersistentVector.java:183)
at clojure.lang.PersistentVector.assocN(PersistentVector.java:21)
at clojure.lang.APersistentVector.assoc(APersistentVector.java:333)
at clojure.lang.APersistentVector.assoc(APersistentVector.java:18)
at clojure.lang.RT.assoc(RT.java:778)
at clojure.core$assoc__4142.invoke(core.clj:191)
at clojure.core$assoc_in.invoke(core.clj:5909)
at auto_parcel.extension$add_last_QMARK_.invoke(extension.clj:65)
at auto_parcel.extension$process.invoke(extension.clj:76)
at clojure.lang.Var.invoke(Var.java:394)
at auto_parcel.AutoParcelExtension.generateClass(AutoParcelExtension.java:61)
at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:424)
at com.google.auto.value.processor.AutoValueProcessor.process(AutoValueProcessor.java:143)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:101)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:50)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:36)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:157)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:139)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have a project in which I just included 'com.neenbedankt.gradle.plugins:android-apt:1.4' to the buildscripts classpath, applied com.neenbedankt.android-apt
as the a gradle plugin, added com.github.frankiesardo:auto-parcel:0.3
as a compile dependency and com.github.frankiesardo:auto-parcel-processor:0.3
as apt dependency.
I am also using org.roboguice:roboguice:3.0.1
for dependency injection. AutoParcel is doing its thing and my unit-tests using the generated classes work just fine. But when I run the app I get the following error:
java.lang.ClassNotFoundException: AnnotationDatabaseImpl
Which is a class generated by Guice at compile time to speed up the construction of the dependency graph. Looking at #11 which refers to another library generating stuff at compile time: could it be that auto-parcel is overwriting the output of other annotation-processors?
I'm using 0.3.0, and the generated builder class method not annotated with @NonNull
/@Nullable
for its return value and params.
LogCat :
cause : java.lang.InstantiationException: Can't instantiate abstract class uk.ivanc.archimvp.model.entities.Campaigns
detailMessage : Failed to invoke public uk.ivanc.archimvp.model.entities.Campaigns() with no args
Campaigns.java
@AutoValue
public abstract class Campaigns implements Parcelable{
public abstract String remaining_days_formatted();
public abstract String end_time_formatted();
public abstract String badge_url();
public abstract String newsletter_urlkey();
public abstract String id_campaign();
public abstract String navigation_url();
public abstract Object promotion_line();
public abstract ImmutableList<Videos> videos();
public abstract String start_time_formatted();
public abstract String subline();
public abstract String banner_url();
public abstract Object banner_url_original();
public abstract String message_line_style();
public abstract String end_time();
public abstract String description();
public abstract String name();
public abstract Images images();
public abstract String start_time();
public abstract String url_key();
public abstract String message_line();
public abstract Object themeday();
public static Builder builder() {
return new AutoValue_Campaigns.Builder();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder remaining_days_formatted(String value);
public abstract Builder end_time_formatted(String value);
public abstract Builder badge_url(String value);
public abstract Builder newsletter_urlkey(String value);
public abstract Builder id_campaign(String value);
public abstract Builder navigation_url(String value);
public abstract Builder promotion_line(Object value);
public abstract Builder videos(ImmutableList<Videos> value);
public abstract Builder start_time_formatted(String value);
public abstract Builder subline(String value);
public abstract Builder banner_url(String value);
public abstract Builder banner_url_original(Object value);
public abstract Builder message_line_style(String value);
public abstract Builder end_time(String value);
public abstract Builder description(String value);
public abstract Builder name(String value);
public abstract Builder images(Images value);
public abstract Builder start_time(String value);
public abstract Builder url_key(String value);
public abstract Builder message_line(String value);
public abstract Builder themeday(Object value);
public abstract Campaigns build();
}
}
Code generated the exception (onError
is called)
public void getCampaigns() {
WestwingApplication application = WestwingApplication.get(campaignsMvpView.getContext());
WestwingService westwingService = application.getWestwingService();
subscription = westwingService.getCampaigns()
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(application.defaultSubscribeScheduler())
.subscribe(new Observer<List<Campaigns>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(List<Campaigns> campaigns) {
campaignsMvpView.showCampaigns(campaigns);
}
});
}
}
AutoParcel's generated class methods do not inherit the abstract skeleton's @nonnull and @nullable annotations. IDEs will then warn developers that "Overriden methods are not annotated".
@AutoParcel
abstract class SomeModel implements Parcelable {
@NonNull //Overriden methods are not annotated
abstract String name();
}
Can AutoParcel annotate the generated methods with the same annotations?
Thanks.
With given
@AutoValue
public abstract class Example implements Parcelable{
@AutoValue.Builder
public abstract static class Builder {
public abstract Example build();
}
public abstract Builder toBuilder();
}
AutoParcel generates
final class AutoValue_Example extends $AutoValue_Example {
private final static ClassLoader CL = AutoValue_Example.class.getClassLoader();
public AutoValue_Example (
Example.Builder toBuilder
) {
super(
toBuilder
);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(toBuilder());
}
private AutoValue_Example(Parcel in) {
this(
(Example.Builder) in.readValue(CL)
);
}
public static final Parcelable.Creator<AutoValue_Example> CREATOR = new Parcelable.Creator<AutoValue_Example>() {
@Override
public AutoValue_Example createFromParcel(Parcel in) {
return new AutoValue_Example(in);
}
@Override
public AutoValue_Example[] newArray(int size) {
return new AutoValue_Example[size];
}
};
}
Which leads to compile errors
Hey, is there anything wrong with jcenter? I really don't want to be adding yet another repos to my build...
First time I ran the app with AutoParcel enabled was ok. But the next run throws this error and the won't run unless I remove
compile 'frankiesardo:auto-parcel:1.0.3'
annotationProcessor 'frankiesardo:auto-parcel:1.0.3'
from build.gradle
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK project.clj
File1: /Users/admin/.gradle/caches/modules-2/files-2.1/stencil/stencil/0.3.5/395c7f24901890f367387a122266b201d3008205/stencil-0.3.5.jar
File2: /Users/admin/.gradle/caches/modules-2/files-2.1/slingshot/slingshot/0.10.3/ea80c69fdeb11687a3bd1ba6bb30ec4a41eea7a0/slingshot-0.10.3.jar
File3: /Users/admin/.gradle/caches/modules-2/files-2.1/quoin/quoin/0.1.2/dbbb28df3e337233f934468915eb327ff488172/quoin-0.1.2.jar
I'm getting Error:Could not find com.neenbedankt.gradle.plugins:android-apt:0.3
What am I missing?
top level build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:0.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
module level gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.tinchoapps.autoparceltest"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.github.frankiesardo:auto-parcel:0.3'
apt 'com.github.frankiesardo:auto-parcel-processor:0.3'
}
Thanks in advance
I had an erroneous Object
type in one of my classes which was being filled with a type that was not parcelable. Parcel
's writeValue
does take an Object
but it's very specific about which types are allowed: https://developer.android.com/reference/android/os/Parcel.html#writeValue(java.lang.Object).
I want my build to fail if a type is used that does not meet these requirements.
According to the readme of Google Auto, there should be support for property-methods (e.g. int numberOfLegs()) and autoBuild() method in builders: https://github.com/google/auto/tree/master/value#other-preconditions-or-preprocessing
Auto-Parcel however is still lacking this feature and only allows setters and a build method.
Builder toBuilder() function is included in the constructor for the auto generated parcel code.
Error:(128, 14) error: no suitable constructor found for AutoValue_TestSection(String,List<QuoteGroup>,Integer)
constructor AutoValue_TestSection.AutoValue_TestSection(String,List<QuoteGroup>,Integer,Builder) is not applicable
(actual and formal argument lists differ in length)
constructor AutoValue_TestSection.AutoValue_TestSection(Parcel) is not applicable
(actual and formal argument lists differ in length)
Example class.
@AutoValue @AutoGson public abstract class TestSection implements Parcelable, Comparable<TestSection> {
public abstract String name();
public abstract List<QuoteGroup> quoteGroups();
public abstract Integer id();
public abstract Builder toBuilder();
@Override public int compareTo(@NonNull TestSection testSection) {
return id().compareTo(testSection.id());
}
@AutoValue.Builder public abstract static class Builder {
public abstract Builder name(String name);
public abstract Builder quoteGroups(List<QuoteGroup> quoteGroups);
public abstract Builder id(Integer id);
public abstract TestSection build();
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.