I am following the AWS Android Amplify module 5 API and Database implementation guide but I encountered an error where I am unable to build the project due to unresolved symbols in the NoteData.java file which is automatically generated by Amplify representing my data schema.
Upon inspecting the ModelConfig.java file, I realized that the parameters for both "type" and "version" were not implemented in the ModelConfig.java. Are these parameters necessary and should they be deleted?
package com.amplifyframework.core.model.annotations;
import com.amplifyframework.core.model.Model;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* {@link ModelConfig} annotates any {@link Model} with applicable configuration information.
*
* The {@link RetentionPolicy#RUNTIME} annotation is added to
* retain {@link ModelConfig} at runtime for the reflection capabilities to work
* in order to check if this annotation is present for a field of a Model.
*
* {@link ElementType#TYPE} annotation is added to indicate
* {@link ModelConfig} annotation can be used only on types (class, interface, enum).
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ModelConfig {
/**
* Specifies the plural version of the model name.
* @return the plural version of the name.
*/
String pluralName() default "";
/**
* Specifies an array of authorization rules that should apply to this {@link Model}.
* @return list of {@link AuthRule} annotations.
*/
AuthRule[] authRules() default {};
}
import static com.amplifyframework.core.model.query.predicate.QueryField.field;
/** This is an auto generated class representing the NoteData type in your schema. */
@SuppressWarnings("all")
@ModelConfig(pluralName = "NoteData", type = Model.Type.USER, version = 1, authRules = {
@AuthRule(allow = AuthStrategy.OWNER, ownerField = "owner", identityClaim = "cognito:username", provider = "userPools", operations = { ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE, ModelOperation.READ })
})
2
Answers
Apparently, It seems to work without the parameters. I can remove the 2 parameters m type and version. It works just fine.
You should be following the ModelConfig.java file's implementation.
https://docs.amplify.aws/start/getting-started/generate-model/q/integration/android/
Looks like
targetNames
parameter for@BelongsTo
(on the amplify generated model) hasn’t been implemented too. Discarding the parameter should work fine as well.