Comments (14)
Caused by: java.lang.NoClassDefFoundError: android/content/ContentValues
at ollie.internal.codegen.writer.ModelAdapterWriter.writeImports(ModelAdapterWriter.java:105)
at ollie.internal.codegen.writer.ModelAdapterWriter.writeSource(ModelAdapterWriter.java:88)
at ollie.internal.codegen.writer.ModelAdapterWriter.writeSource(ModelAdapterWriter.java:41)
at ollie.internal.codegen.step.ModelAdapterStep.process(ModelAdapterStep.java:71)
at ollie.internal.codegen.OllieProcessor.process(OllieProcessor.java:76)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
... 66 more
I work in android studio.
from ollie.
@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
}
from ollie.
Thanks for sharing your workaround @donaldlittlepie. It worked for me.
from ollie.
I spoke too soon. I switched back on proguard via minifyEnabled true
and now I'm getting the following error:
Execution failed for task ':app:proguardDebug'.
> java.io.IOException: The same input jar [/path/to/android-sdk/platforms/android-21/android.jar] is specified twice.
When I remove the provided files("${props["sdk.dir"]}/platforms/android-21/android.jar")
line and leave minifyEnabled true
, it reverts to the original error of this issue report.
from ollie.
@carltonwhitehead sorry about that. I wasn't at the point of trying to proguard my files.
from ollie.
and then I get:
warning: File for type 'ollie.AdapterHolderImpl' created in the last round will not be subject to annotation processing.
from ollie.
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.
from ollie.
Thanks Michael.
Now I can test ollie. :-)
from ollie.
Can you guys try the latest snapshot and see if things have improved?
from ollie.
Relevant lines from my build.gradle:
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
compile 'com.michaelpardo:ollie:0.3.0-SNAPSHOT'
provided 'com.michaelpardo:ollie-compiler:0.3.0-SNAPSHOT'
}
When I do ./gradlew clean assembleDebug
, I still get the same error.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:_compileDebugJava'.
> java.lang.NoClassDefFoundError: android/content/ContentValues
Is 0.3.0-SNAPSHOT
the correct version? I picked it based on https://github.com/pardom/ollie/blob/575e12830878a86cc602d38245781a9c66dbb443/gradle.properties
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
from ollie.
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.
from ollie.
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).
from ollie.
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.
from ollie.
Thanks @pardom
from ollie.
Related Issues (20)
- [question] where should I initialize the Ollie? HOT 2
- [question] How can I specify indexes for my model/table?
- Robolectric unit tests failing when using Ollie
- BigDecimal results in cursor.null() in ModelAdapter HOT 1
- Add ability to close database and reopen it - robolectric requirement
- byte[] arrays result in NPE
- No support for aar files HOT 1
- Does Ollie support multiple DB in one app?
- Using with Eclipse
- Cursor doesn't close in Selection
- Concurrency issues
- NullPointerException
- Trouble upgrading database HOT 2
- Any active development? HOT 2
- Multiple Conditions? HOT 2
- AutoValue Usage
- Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > java.lang.NullPointerException HOT 3
- Relations like one-to-many, many-to-many, etc HOT 1
- RxJava 2.x support HOT 1
- Ollie Deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ollie.