chennaione / sugar

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

NoClassDefFoundError: com.google.android.gms.internal.zzeho #768

Open fermatijoe opened 7 years ago

fermatijoe commented 7 years ago

Hi, I get a crash when I open an activity that uses SugarORM.

E/AndroidRuntime: FATAL EXCEPTION: main
                                                               Process: com.dcs.wallhouse, PID: 13999
                                                               java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzeho
                                                                   at java.lang.Class.classForName(Native Method)
                                                                   at java.lang.Class.forName(Class.java:324)
                                                                   at com.orm.util.ReflectionUtil.getDomainClass(ReflectionUtil.java:270)
                                                                   at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:254)
                                                                   at com.orm.SchemaGenerator.createDatabase(SchemaGenerator.java:37)
                                                                   at com.orm.SugarDb.onCreate(SugarDb.java:26)
                                                                   at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
                                                                   at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
                                                                   at com.orm.SugarDb.getDB(SugarDb.java:36)
                                                                   at com.orm.SugarRecord.find(SugarRecord.java:189)
                                                                   at com.orm.query.Select.list(Select.java:118)
                                                                   at com.dcs.wallhouse.utils.FavouriteUtils.getListFromDb(FavouriteUtils.java:42)
                                                                   at com.dcs.wallhouse.utils.FavouriteUtils.checkIfThisIsFavorite(FavouriteUtils.java:27)
                                                                   at com.dcs.wallhouse.DetailActivity.onResume(DetailActivity.java:219)
                                                                   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258)
                                                                   at android.app.Activity.performResume(Activity.java:6312)
                                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
                                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
                                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

The line where it is crashing:

@Override
protected void onResume() {
    if(FavouriteUtils.checkIfThisIsFavorite(mWallpaper)) {
        Log.v(LOG_TAG, "Wallpaper already in fav");
        mFavouriteIv.setImageResource(R.drawable.ic_favorite_black_24dp);
    }else if(!FavouriteUtils.checkIfThisIsFavorite(mWallpaper)) {
        Log.v(LOG_TAG, "Wallpaper not in fav");
        mFavouriteIv.setImageResource(R.drawable.ic_favorite_border_black_24dp);
    }
    super.onResume();
}

My FavouriteUtls class:

`public class FavouriteUtils {
private final static String WHERE_CLAUSE_ID = "m_url";

public static void addThisToFavorites(Wallpaper s){
    s.save();
    Log.v("FAVUTILS", "item added from fav");
}

public static void removeThisFromFavorites(Wallpaper s){
    getListFromDb(s, WHERE_CLAUSE_ID).get(0).delete();
    Log.v("FAVUTILS", "item removed from fav");
}

public static boolean checkIfThisIsFavorite(Wallpaper s){
    List<Wallpaper> results = getListFromDb(s, WHERE_CLAUSE_ID);
    if(results.size() > 0){
        //found match
        return true;
    }else {
        //no match
        return false;
    }
}
private static List<Wallpaper> getListFromDb(Wallpaper s, String whereClause){
    //check for unique walls by URL (since earth sat walls doesn't have ids)
    String wallId = s.getUrl();
    return Select.from(Wallpaper.class)
                    .where(Condition.prop(whereClause)
                    .eq(wallId))
            .list();
}

public static List<Wallpaper> getAllFavorites(){
    return Wallpaper.listAll(Wallpaper.class);
}

}`

my dependencies:

`compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.github.GrenderG:Toasty:1.2.3'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
testCompile 'junit:junit:4.12'
compile 'com.android.support:palette-v7:24.2.1'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile('com.mikepenz:materialdrawer:5.9.1@aar') {
    transitive = true
}
compile 'com.github.satyan:sugar:1.3'
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.google.android.gms:play-services-ads:11.2.0'`

my manifest:

`<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:replace="android:icon"
    android:name="com.orm.SugarApp">

    <meta-data android:name="DATABASE" android:value="mydatabase.db" />
    <meta-data android:name="VERSION" android:value="2" />
    <meta-data android:name="QUERY_LOG" android:value="true" />`
fermatijoe commented 7 years ago

It looks like it works if i remove the

compile 'com.google.android.gms:play-services-ads:11.2.0'`

Why is that so? How can I fix this?