-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
model error #17
Comments
Caused by: java.lang.NoClassDefFoundError: android/content/ContentValues I work in android studio. |
@jiqimaogou I ran into the same issue. It looks like the annotation processor needs the android.jar at compile time. I included the android.jar as a 'provided' dependency. I'm not sure if there is a better way to get around this issue. I would have assumed that I wouldn't need to explicitly do this, but I'm not sure how the android gradle plugin lifecycle works with ollie. I ended up with the following build.gradle file which loads my android sdk path from local.properties and adds the android jar a provided dependency. I got the idea from the ollie build file. //... removed for brevity
// Find my sdk path
def Properties props = new Properties()
props.load(new FileInputStream(file('../local.properties')))
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.0'
//... removed for brevity
defaultConfig {
minSdkVersion 16 // Can't use try-resource blocks unless min at least 19
targetSdkVersion 21 // roboelectric issue needs 18
versionCode 1
versionName "1.0"
}
// ... remove for brevity
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
... // removed for brevity
provided files("${props["sdk.dir"]}/platforms/android-21/android.jar") // provide android.jar for ollie
} |
Thanks for sharing your workaround @donaldlittlepie. It worked for me. |
I spoke too soon. I switched back on proguard via
When I remove the |
@carltonwhitehead sorry about that. I wasn't at the point of trying to proguard my files. |
and then I get: |
Don't worry about that warning. It just means that the class which Ollie created won't be processed, i.e. no recursive processing. I'll look in to the above and making sure that dependencies are self-contained. |
Thanks Michael. |
Can you guys try the latest snapshot and see if things have improved? |
Relevant lines from my build.gradle:
When I do
Is EDIT: I just went through https://oss.sonatype.org/content/repositories/snapshots/com/michaelpardo/ollie/0.3.0-SNAPSHOT/ and compared the md5 for the jar with the timestamp from today with the one in my local gradle cache, and it was a match. Pretty sure this means whatever you changed didn't solve it. Is it working for you locally? Perhaps there's an environment configuration coming into play here. EDIT 2: Same error with both ollie-0.3.0-20141211.150943-6.jar and ollie-0.3.0-20141211.161608-7.jar |
Yeah, that's it. I'm seeing that on my end too. Provided dependencies aren't really supported natively by Gradle so I'm trying a few things to get this working. I'll post an update when I figure it out. |
Just a note: I made a change (removed LruCache) which requires support-v4, so you'll need to add that jar too, until I figure out this issue (if you're using the snapshot). |
Okay, this has been fixed and pushed to snapshots. The problem was that the compiler was using Android classes to safely get import class names by type. I switched these out for strings and removed the Android dependency. |
Thanks @pardom |
when I define a model, and then run the app, it has errors.
Error:Execution failed for task ':app:compileDebugJava'.
i Use api 21.
The text was updated successfully, but these errors were encountered: