Giter Club home page Giter Club logo

Comments (14)

jiqimaogou avatar jiqimaogou commented on August 27, 2024

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.

wontondon avatar wontondon commented on August 27, 2024

@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.

carltonwhitehead avatar carltonwhitehead commented on August 27, 2024

Thanks for sharing your workaround @donaldlittlepie. It worked for me.

from ollie.

carltonwhitehead avatar carltonwhitehead commented on August 27, 2024

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.

wontondon avatar wontondon commented on August 27, 2024

@carltonwhitehead sorry about that. I wasn't at the point of trying to proguard my files.

from ollie.

Rainer-Lang avatar Rainer-Lang commented on August 27, 2024

and then I get:
warning: File for type 'ollie.AdapterHolderImpl' created in the last round will not be subject to annotation processing.

from ollie.

pardom-zz avatar pardom-zz commented on August 27, 2024

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.

Rainer-Lang avatar Rainer-Lang commented on August 27, 2024

Thanks Michael.
Now I can test ollie. :-)

from ollie.

pardom-zz avatar pardom-zz commented on August 27, 2024

Can you guys try the latest snapshot and see if things have improved?

from ollie.

carltonwhitehead avatar carltonwhitehead commented on August 27, 2024

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.

pardom-zz avatar pardom-zz commented on August 27, 2024

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.

pardom-zz avatar pardom-zz commented on August 27, 2024

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.

pardom-zz avatar pardom-zz commented on August 27, 2024

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.

carltonwhitehead avatar carltonwhitehead commented on August 27, 2024

Thanks @pardom

from ollie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.