我试图在我的Android项目中使用Parceler库。该项目有两个模块,一个是应用程序本身,另一个是个人android核心库,包含各种帮助程序和通用实体。
但是,我在我的核心库中添加了Parceler依赖项,因为我也需要它,所以在库build.gradle中我添加了以下几行:
compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"我没有在应用程序build.gradle文件中指定这些行,因为来自Parceler的依赖项将自动导入。
在我的应用程序中,我定义了一个必须是Parcelable的实体,其实现是:
@Parcel
public class Course {
public String name;
public Course() { /*Required empty bean constructor*/ }
public Course(String name) {
this.name = name;
}
}但当我试着做
Course[] courses = ...retrieved from server...
Parcelable p = Parcels.wrap(courses);该框架触发以下异常:
org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for [Lit.bmsoftware.lotoapp.network.entity.Course;, verify that your class is configured properly and that the Parcelable class [Lit.bmsoftware.lotoapp.network.entity.Course;$$Parcelable is generated by Parceler.我已经看过很多关于这个例外的文章,但是我找不到解决问题的方法。
有人能帮我吗?
(预先谢谢:)
编辑: build.gradle文件
plugins {
id "me.tatarka.retrolambda" version "3.2.4"
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
retrolambda {
jvmArgs '-noverify' // Issues: using Google Play Services causes retrolambda to fail
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "it.bmsoftware.lotoapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
storeFile file("*******.keystore")
storePassword "********"
keyAlias "*******"
keyPassword "*******"
}
}
buildTypes {
release {
//noinspection GroovyAssignabilityCheck
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
mavenLocal()
}
dataBinding {
enabled = true
}
// Fixes bug in Data Binding library (Source folders generated at incorrect location)
// applicationVariants.all { variant ->
// def variantName = variant.name.capitalize()
// def inputDir = "${buildDir}/intermediates/classes/${variant.dirName}"
// def sourceDir = "${buildDir}/generated/source/dataBinding/${variant.dirName}"
// def copyTask = tasks.create(name: "dataBindingFix${variantName}", type: Copy) {
// from inputDir
// into sourceDir
// include '**/*.java'
// }
// tasks["generate${variantName}Sources"].dependsOn copyTask
// variant.addJavaSourceFoldersToModel new File(sourceDir)
// }
return true
}
ext {
supportLibVersion = '23.1.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':core')
compile "com.android.support:support-v13:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
//compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"
compile 'jp.wasabeef:recyclerview-animators:2.2.0'
}发布于 2016-02-13 05:21:38
当前版本(1.0.4)不支持通过@Parcel实用程序类对Parcels进行注释的类数组。相反,我建议使用List
List<Course> courses = ...retrieved from server...
Parcelable p = Parcels.wrap(courses);https://stackoverflow.com/questions/35088329
复制相似问题