chennaione / sugar

Insanely easy way to work with Android Database.
http://satyan.github.com/sugar/
MIT License
2.62k stars 583 forks source link

java.lang.NoClassDefFoundError: org.hamcrest.Matcher[] #184

Closed heatherSnepenger closed 10 years ago

heatherSnepenger commented 10 years ago

I'm having an issue running my app when I true to access the database. I get the following error:

java.lang.NoClassDefFoundError: org.hamcrest.Matcher[]

I don't have the Expresso or anything else installed in my app. I check Sugar's gradle file, and it didn't seem to require it. I tried installing Expresso by adding the following to my build.gradle file:

    androidTestCompile files('libs/espresso-1.1.jar', 'libs/testrunner-1.1.jar', 'libs/testrunner-runtime-1.1.jar')
    androidTestCompile 'com.google.guava:guava:14.0.1'
    androidTestCompile 'com.squareup.dagger:dagger:1.1.0'
    androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.1'

    androidTestCompile('junit:junit:4.11') {
        exclude module: 'hamcrest-core'
    }
    androidTestCompile('org.robolectric:robolectric:2.3') {
        exclude module: 'classworlds'
        exclude module: 'commons-logging'
        exclude module: 'httpclient'
        exclude module: 'maven-artifact'
        exclude module: 'maven-artifact-manager'
        exclude module: 'maven-error-diagnostics'
        exclude module: 'maven-model'
        exclude module: 'maven-project'
        exclude module: 'maven-settings'
        exclude module: 'plexus-container-default'
        exclude module: 'plexus-interpolation'
        exclude module: 'plexus-utils'
        exclude module: 'wagon-file'
        exclude module: 'wagon-http-lightweight'
        exclude module: 'wagon-provider-api'
    }
    androidTestCompile 'com.squareup:fest-android:1.0.+'

but I still got the crash.

Here's my stacktrace:

11-05 19:48:00.926 27063-27063/? E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:217) at com.orm.SugarDb.getDomainClass(SugarDb.java:60) at com.orm.SugarDb.getDomainClasses(SugarDb.java:41) at com.orm.SugarDb.createDatabase(SugarDb.java:104) at com.orm.SugarDb.onCreate(SugarDb.java:100) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) at com.orm.Database.getDB(Database.java:18) at com.orm.SugarRecord.save(SugarRecord.java:45) at com.package.wine.requests.CollectionRequest.processCollectionWines(CollectionRequest.java:99) at com.package.wine.requests.CollectionRequest.getCollectionWineList(CollectionRequest.java:73) at com.package.wine.activities.collections.CollectionDetailActivity.setupData(CollectionDetailActivity.java:203) at com.package.wine.util.MasterActivity.setContentView(MasterActivity.java:46) at com.package.wine.activities.collections.CollectionDetailActivity.onCreate(CollectionDetailActivity.java:121) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: org.hamcrest.Matcher[] at com.google.android.apps.common.testing.ui.espresso.Espresso.<clinit>(Espresso.java:120)             at java.lang.Class.classForName(Native Method)             at java.lang.Class.forName(Class.java:217)             at com.orm.SugarDb.getDomainClass(SugarDb.java:60)             at com.orm.SugarDb.getDomainClasses(SugarDb.java:41)             at com.orm.SugarDb.createDatabase(SugarDb.java:104)             at com.orm.SugarDb.onCreate(SugarDb.java:100)             at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)             at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)             at com.orm.Database.getDB(Database.java:18)             at com.orm.SugarRecord.save(SugarRecord.java:45)             at com.package.wine.requests.CollectionRequest.processCollectionWines(CollectionRequest.java:99)             at com.package.wine.requests.CollectionRequest.getCollectionWineList(CollectionRequest.java:73)             at com.package.wine.activities.collections.CollectionDetailActivity.setupData(CollectionDetailActivity.java:203)             at com.package.wine.util.MasterActivity.setContentView(MasterActivity.java:46)             at com.package.wine.activities.collections.CollectionDetailActivity.onCreate(CollectionDetailActivity.java:121)             at android.app.Activity.performCreate(Activity.java:5104)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)             at android.app.ActivityThread.access$600(ActivityThread.java:141)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5041)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)             at dalvik.system.NativeStart.main(Native Method)

satyan commented 10 years ago

Most probably dagger may be using it internally.. Can you share your AndroidManifest metadata tags. If you add the DOMAIN_PACKAGE_NAME metadata, it should fix it.

heatherSnepenger commented 10 years ago

I did take out the DOMAIN_PACKAGE_NAME because I was getting errors with that metadata in there...What should the package name be? the name of my project package?

On Wed, Nov 5, 2014 at 3:19 PM, Satya Narayan notifications@github.com wrote:

Most probably dagger may be using it internally.. Can you share your AndroidManifest metadata tags. If you add the DOMAIN_PACKAGE_NAME metadata, it should fix it.

— Reply to this email directly or view it on GitHub https://github.com/satyan/sugar/issues/184#issuecomment-61874238.

heatherSnepenger commented 10 years ago

That was the issue. I added the DOMAIN_PACKAGE_NAME back, and the issue was resolved