2017-02-22 36 views
0

編輯Parceler - 無法找到產生Parcelable類

清潔後和重建,類不能產生


試圖使用Parcels.wrap()

Unable to find generated Parcelable class for xyz.xyz.models.reclamation.Reclamation, verify that your class is configured properly and that the Parcelable class xyz.xyz.models.reclamation.Reclamation$$Parcelable is generated by Parceler. 

我得到這個錯誤但Reclamation$$Parcelable類已創建,我可以看到它的內容。

這就是我的gradle產出:

compile 'org.parceler:parceler-api:1.1.6' 
annotationProcessor 'org.parceler:parceler:1.1.6' 

試圖改變annotationProcessorapt原因建立自己的錯誤。

那開墾類

@Parcel 
public class Reclamation { 

public Reclamation() { 
} 

private int reclamationProductID; 

private Integer preference; 

private String takingDate1; 

private String takingDate2; 

private int takingAddressID; 

private String takingAddressStreet; 

private String takingAddressCity; 

private String takingAddressZipCode; 

private int type; 

private String takingAddressCompany; 
// + getters setters 
} 

那它崩潰

ServiceStepFour_.builder().arg(Constants.ARG_RECLAMATION, Parcels.wrap(reclamation)).build(); 

我用它在與Android註解組合的線。

有誰知道爲什麼會發生這種情況?

+0

你的ProGuard在構建配置的任何機會呢? –

回答

2

雖然文件說,你必須把這些線路的gradle產出:

compile 'org.parceler:parceler-api:1.1.6' 
annotationProcessor 'org.parceler:parceler:1.1.6' 

將其更改爲:

compile 'org.parceler:parceler-api:1.1.6' 
apt 'org.parceler:parceler:1.1.6' 

確保您要使用的所有文件與@Parcel註解。

我有A級變量,B級變量,我忘了標註B級。這就是爲什麼從annotationProcessor改爲apt給了我一個構建錯誤。

+0

哦,你是否已經使用apt和android註釋了? –

+0

@JohnEricksen很高興認識你:)是的,我使用apt來代替annotationProcessor – kristyna

1

就我而言,我不得不刪除線的時候,我從易於移動到annotationProcessor

apply plugin: 'com.neenbedankt.android-apt' 
相關問題