Closed rhapsodixx closed 9 years ago
Hi @panjigautama A search on Stack Overflow seem to indicate that it is an issue with AndroidAnnotations, see eg. this post here: http://stackoverflow.com/questions/22300146/android-annotations-build-fails-on-android-studio-0-5-1
Can you post your CartItem model class?
Hi !
if i build it without realm it will run perfectly.
public class CartItem extends RealmObject {
private String item_id;
private int weight;
private int base_weight;
private int quantity;
private String item_reference_id;
private String name;
private String description;
private String item_image;
private int vendor_id;
private String vendor_name;
private String vendor_image;
private String attributes;
// generated getter & setter
}
Hi @panjigautama
That is not the whole class, you are missing getters and setters?
Also, the RealmObject class has a @RealmClass annotation which might be conflicting with something inside AndroidAnnotations. Can you post the entire output from gradle when doing ./gradlew clean assemble
?
Ah sorry, i don't post entire getter & setter because it's a standar getter & setter generated by android studio.
@RealmClass
public class CartItem extends RealmObject {
private String item_id;
private Double price;
private Double base_price;
private int weight;
private int base_weight;
private int quantity;
private String item_reference_id;
private String name;
private String description;
private String item_image;
private int vendor_id;
private String vendor_name;
private String vendor_image;
private String attributes;
private Date date_added;
public String getItem_id() {
return item_id;
}
public void setItem_id(String item_id) {
this.item_id = item_id;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Double getBase_price() {
return base_price;
}
public void setBase_price(Double base_price) {
this.base_price = base_price;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getBase_weight() {
return base_weight;
}
public void setBase_weight(int base_weight) {
this.base_weight = base_weight;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getItem_reference_id() {
return item_reference_id;
}
public void setItem_reference_id(String item_reference_id) {
this.item_reference_id = item_reference_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getItem_image() {
return item_image;
}
public void setItem_image(String item_image) {
this.item_image = item_image;
}
public int getVendor_id() {
return vendor_id;
}
public void setVendor_id(int vendor_id) {
this.vendor_id = vendor_id;
}
public String getVendor_name() {
return vendor_name;
}
public void setVendor_name(String vendor_name) {
this.vendor_name = vendor_name;
}
public String getVendor_image() {
return vendor_image;
}
public void setVendor_image(String vendor_image) {
this.vendor_image = vendor_image;
}
public String getAttributes() {
return attributes;
}
public void setAttributes(String attributes) {
this.attributes = attributes;
}
public Date getDate_added() {
return date_added;
}
public void setDate_added(Date date_added) {
this.date_added = date_added;
}
}
I also tried @RealmClass annotation with no luck.
The entire error output quite long though, because android annotation fail to read file generated by realm (the file still unclosed). I'll post it later.
i still have no luck building realm with android annotation , is there any clue ?
Can you post the complete build log from ./gradlew clean assemble
?. If you are not comfortable posting it here you can send it to help@realm.io for full confidentiality.
Closing due to no response. Please feel free to reopen if you have additional information.
It is due to certain data types not supported in realm. You need to create a realm version of it. I suspect it is the "Date".
Can also happen if you forget to use RealmList<>
in place of List<>
🙈
@david201601 actually the question was from 2015 meaning there was no NULL support, meaning it was actually the Double
field instead of double
.
This is supported since 0.83.0.
Indeed. I wasn't trying to suggest that RealmList
was the answer to the original issue (in fact, they didn't even use List
).
I googled my error and ended up here, and it was enough to make me realise what mistake I had made. So in anticipation of others having the same issue I left my comment.
@csdodd I know, I commented to the person above you from 2016, because Date
was not the problem :)
@cmelchior
D:\Projectz\android-sample>gradlew clean assemble
Parallel execution is an incubating feature.
> Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Observed package id 'build-tools;20.0.0' in inconsistent location 'D:\androidSdk\sdk\build-tools\android-4.4W' (Expected 'D:\androidSdk\sdk\build-tools\20.0.0')
Observed package id 'platforms;android-17' in inconsistent location 'D:\androidSdk\sdk\platforms\android-4.2' (Expected 'D:\androidSdk\sdk\platforms\android-17')
Observed package id 'system-images;android-10;default;x86' in inconsistent location 'D:\androidSdk\sdk\system-images\android-10\x86' (Expected 'D:\androidSdk\sdk\system-images\android-10\default\x86')
Observed package id 'system-images;android-15;default;mips' in inconsistent location 'D:\androidSdk\sdk\system-images\android-15\mips' (Expected 'D:\androidSdk\sdk\system-images\android-15\default\mips')
Observed package id 'system-images;android-16;default;mips' in inconsistent location 'D:\androidSdk\sdk\system-images\android-16\mips' (Expected 'D:\androidSdk\sdk\system-images\android-16\default\mips')
Observed package id 'system-images;android-17;default;mips' in inconsistent location 'D:\androidSdk\sdk\system-images\android-17\mips' (Expected 'D:\androidSdk\sdk\system-images\android-17\default\mips')
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
> Configure project :myApp
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
> Task :app:processDebugGoogleServices
Parsing json file: D:\Projectz\android-sample\app\google-services.json
> Task :app:processReleaseGoogleServices
Parsing json file: D:\Projectz\android-sample\app\google-services.json
> Task :topsnackbar:compileDebugJavaWithJavac
Note: D:\Projectz\android-sample\topsnackbar\src\main\java\com\androidadvance\topsnackbar\TSnackbar.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :topsnackbar:compileReleaseJavaWithJavac
Note: D:\Projectz\android-sample\topsnackbar\src\main\java\com\androidadvance\topsnackbar\TSnackbar.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :app:processDebugManifest
D:\Projectz\android-sample\app\src\main\AndroidManifest.xml:78:17-79:46 Warning:
action#android.intent.action.VIEW was tagged at AndroidManifest.xml:78 to remove other declarations but no other declaration present
D:\Projectz\android-sample\app\src\main\AndroidManifest.xml:80:17-81:48 Warning:
category#android.intent.category.DEFAULT was tagged at AndroidManifest.xml:80 to remove other declarations but no other declaration present
D:\Projectz\android-sample\app\src\main\AndroidManifest.xml:82:17-83:48 Warning:
category#android.intent.category.BROWSABLE was tagged at AndroidManifest.xml:82 to remove other declarations but no other declaration present
D:\Projectz\android-sample\app\src\main\AndroidManifest.xml:84:17-87:44 Warning:
data was tagged at AndroidManifest.xml:84 to remove other declarations but no other declaration present
Download https://maven.google.com/com/android/databinding/compiler/3.0.1/compiler-3.0.1.pom
Download https://maven.google.com/com/android/databinding/compiler/3.0.1/compiler-3.0.1.jar
> Task :myApp:compileDebugJavaWithJavac
D:\Projectz\android-sample\myApp\src\main\java\com\packagename\ProductActivity.java:77: error: package com.packagename.databinding does not exist
import com.packagename.databinding.ActivityProductBinding;
^
D:\Projectz\android-sample\myApp\src\main\java\com\packagename\ProductActivity.java:78: error: package com.packagename.databinding does not exist
import com.packagename.databinding.CommentProductBinding;
^
D:\Projectz\android-sample\myApp\src\main\java\com\packagename\ProductActivity.java:111: error: cannot find symbol
protected ActivityProductBinding binding;
^
symbol: class ActivityProductBinding
location: class ProductActivity
...
...
...
Note: Version 4.3.1 of Realm is now available: http://static.realm.io/downloads/java/latest
Note: Processing class Product
Note: Creating DefaultRealmModule
warning: Unclosed files for the types '[io.realm.ProductRealmProxy]'; these types will not undergo annotation processing
100 errors
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myApp:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 4m 11s
100 actionable tasks: 100 executed
activity_product.xml:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="prod"
type="com.packagename.Model.Product" />
</data>
<RelativeLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="@{prod.productName}"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</layout>
Product.java:
package com.packagename.Model;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.Observable;
import android.databinding.PropertyChangeRegistry;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
public class Product extends RealmObject implements Observable/*BaseObservable*/ {
private String productName;
private float review = 0f;
private boolean available = false;
private List<CustomizedValues> customizedValuesList = new ArrayList<>();
private LinkedHashMap<String, String> color_attributes = new LinkedHashMap<>();
// And other String variables.......
@Ignore
private transient PropertyChangeRegistry mCallbacks;
public Product(String p_productName) {
productName = p_productName;
}
public Product(){
this(null, null, null, null, null, null, null, null, null, null);
}
public String getShortDescription() {
return shortDescription;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
@Bindable
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
if (!discount.equals("")) {
this.discount = discount;
notifyPropertyChanged(com.packagename.BR.discount);
}
}
@Bindable
public String getOld_price() {
return old_price;
}
public void setOld_price(String old_price) {
if (!old_price.equals("")) {
this.old_price = old_price;
notifyPropertyChanged(com.packagename.BR.old_price);
}
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public List<CustomizedValues> getCustomizedValuesList() {
return customizedValuesList;
}
public void setCustomizedValuesList(List<CustomizedValues> customizedValuesList) {
this.customizedValuesList = customizedValuesList;
}
public LinkedHashMap<String, String> getColor_attributes() {
return color_attributes;
}
public void setColor_attributes(LinkedHashMap<String, String> color_attributes) {
this.color_attributes = color_attributes;
}
/**
* Notifies listeners that all properties of this instance have changed.
*/
public synchronized void notifyChange() {
if (mCallbacks != null) {
mCallbacks.notifyCallbacks(this, 0, null);
}
}
/**
* Notifies listeners that a specific property has changed. The getter for the property
* that changes should be marked with {@link Bindable} to generate a field in
* <code>BR</code> to be used as <code>fieldId</code>.
*
* @param fieldId The generated BR id for the Bindable field.
*/
public void notifyPropertyChanged(int fieldId) {
if (mCallbacks != null) {
mCallbacks.notifyCallbacks(this, fieldId, null);
}
}
@Override
public void addOnPropertyChangedCallback(OnPropertyChangedCallback onPropertyChangedCallback) {
if (mCallbacks == null) {
mCallbacks = new PropertyChangeRegistry();
}
mCallbacks.add(onPropertyChangedCallback);
}
@Override
public void removeOnPropertyChangedCallback(OnPropertyChangedCallback onPropertyChangedCallback) {
if (mCallbacks != null) {
mCallbacks.remove(onPropertyChangedCallback);
}
}
}
@drjacky sounds like a problem in your databinding setup? If you use Kotlin, you need to apply kotlin-kapt, and make sure all annotationProcessor scopes with kapt
@Zhuinden No, I'm not using Kotlin. BTW, I edited the previous comment by adding Product model too.
Oh I seem to be blind,
private List<CustomizedValues> customizedValuesList = new ArrayList<>();
private LinkedHashMap<String, String> color_attributes = new LinkedHashMap<>();
// And other String variables.......
These field types (linked HashMap, list that is not RealmList) are not supported in RealmObjects unless they are explicitly ignored.
@Zhuinden Thanks, It was my fault; I forgot that.
I've used @Ignore
and now the project gets build completely, but when I run the application, I get this error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. android.databinding.tool.util.LoggedErrorException: Found data binding errors. / data binding error msg:Cannot find the setter for attribute 'android:onClick' with parameter type lambda on android.support.constraint.ConstraintLayout. file:D:\Projectz\android-sample\myApp\src\main\res\layout\product_item.xml loc:32:27 - 32:58 \ data binding error / data binding error msg:Cannot find the setter for attribute 'android:tag' with parameter type java.lang.String on android.support.v7.widget.CardView. / data binding error msg:Cannot find the setter for attribute 'android:onClick' with parameter type lambda on android.support.v7.widget.CardView. file:D:\Projectz\android-sample\myApp\src\main\res\layout\wishlist_item.xml // And too many layouts like this; Those which used Product inside.................
For example, product_item.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:apps="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="prod"
type="com.packagename.Model.Product" />
<variable
name="handler"
type="com.see.packagename.Handler.ProductHandler" />
</data>
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{()->handler.onClickProduct(prod)}"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintHorizontal_bias="0.0"
card_view:layout_constraintLeft_toLeftOf="parent"
card_view:layout_constraintRight_toRightOf="parent"
card_view:layout_constraintTop_toTopOf="parent"
card_view:layout_constraintVertical_bias="0.0">
<!-- Blah blah -->
</android.support.constraint.ConstraintLayout>
</layout>
ProductHandler.java:
public class ProductHandler {
private final int mProductActivityRequestCode = 1;
private Context mContext;
private int countOrder=1;
public ProductHandler(Context mContext) {
this.mContext = mContext;
}
public void onClickProduct(Product product) {
((HomeActivity)mContext).showLoading();
Intent in = new Intent(mContext, ((CoreApplication) mContext.getApplicationContext()).getProductActivity());
in.putExtra("product_id", product.getProductId());
in.putExtra("product_name", product.getProductName());
in.putExtra("product_count",countOrder+"");
in.putExtra("product_attr", product.getId_attribute());
((HomeActivity) mContext).startActivityForResult(in, mProductActivityRequestCode);
}
}
@drjacky Maybe should be android:onClick="@{(view)->handler.onClickProduct(prod)}"
@Zhuinden Didn't make any change. :disappointed:
BTW, before I changed the Product model from extends BaseObservable
to extends RealmObject implements Observable
, everything worked great.
@Zhuinden It solved. After I switched to the gradle 3.0
, I changed the compile
to implementation
and etc, but there were some common dependencies which used on the other project's module too.
I had to repeat them on that build.gradle
too, or use api
instead of implementation
. :sparkles:
I have faced similar problem while trying to add uri
field to RealmObject class.
Realm not supports android.net.Uri
as field.
After replacing it with string - that works and compile
I am getting following errors Unclosed files for the types '[io.realm.com_example_myapplication_UserRealmProxy]'; these types will not undergo annotation processing
error: Field "icon" of type "android.graphics.Bitmap" is not supported. Even I have posted my question to stackoverflow did not get any response https://stackoverflow.com/questions/55986785/unclosed-files-for-the-types-io-rearealm-com-example-myapplication-userrealmpr
Bitmap icon;
is a field that is not supported by Realm, because there are only certain types that Realm supports. The error message is quite clear about this.
i got this error when trying to build project with realm :
File that generated by realm seems not processed.
I use android annotation and JDK 1.7 Android Studio 1.1 Beta 4