Skip to content
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

Avoid EncryptedHelper ART warning due to missing SQLCipher super class #428

Closed
brian2694 opened this issue Aug 31, 2016 · 48 comments
Closed
Assignees
Milestone

Comments

@brian2694
Copy link

brian2694 commented Aug 31, 2016

Today I've updated to version 3.1.1

When I launch the app, I make a request and pass the data to db.
Since the new update I watch this warning, is it normal? Excuse for my english


Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
Rejecting re-init on previously-failed class java.lang.Class org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper
@brian2694
Copy link
Author

brian2694 commented Aug 31, 2016

I've obtained this warnirng in this line.
final DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, MyStrings.database, null);

Please look the way that I do.

final Database db;
final DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, MyStrings.database, null);
db = helper.getWritableDb();
final DaoMaster daoMaster = new DaoMaster(db);
final DaoSession daoSession = daoMaster.newSession();

@greenrobot
Copy link
Owner

Please tell us on which device and Android version you are seeing this.

@brian2694
Copy link
Author

Lenovo PHAB 750M

@iielse
Copy link

iielse commented Sep 12, 2016

I've updated 2.X to version 3.1.1

/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>

my code:

public class App extends Application {

    private static App instance;
    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
    }

    public static synchronized App i() {
        return instance;
    }

    public DaoSession getDaoSession() {
        if (daoSession == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "user-db", null);
            DaoMaster daoMaster = new DaoMaster(helper.getWritableDatabase());
            daoSession = daoMaster.newSession();
        }
        return daoSession;
    }
}

image

but it can be still work.

@greenrobot-team
Copy link
Collaborator

Do you guys include the greendao JAR manually? Try to add it via a Gradle dependency. Found a similar issue on the Android bug tracker. -ut

@greenrobot-team greenrobot-team self-assigned this Sep 19, 2016
@greenrobot-team
Copy link
Collaborator

This realm bug might also be of interest, issue was with how RxJava support is "loaded". -ut

@greenrobot-team
Copy link
Collaborator

No response. Closing. -ut

@umesh0492
Copy link

umesh0492 commented Jan 15, 2017

@greenrobot-team @greenrobot The same issue on xiaomi mi note 3 with marshmallow with latest version of lib

@baylonedward
Copy link

Also having the same issue on xiaomi mi note 3 marshmallow

@greenrobot-team
Copy link
Collaborator

@umesh0492 @baylonedward Can you show me how you are including greenDAO in your Gradle config files? Are you adding it as a JAR or Gradle dependency? -ut

@weidongjian
Copy link

I hava the same problem in my phone, YQ601, Android Version:5.1.1
I added the greendao with Gradle dependency not jar.

@Syex
Copy link

Syex commented Feb 8, 2017

@greenrobot-team Came here from Google because I saw all these warnings, too, in Logcat. Huawei Honor 7 with Android 6.0

I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/art: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>
I/greenDAO: Creating tables for schema version 1

Gradle:
compile 'org.greenrobot:greendao:3.2.0'

Code:

DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, DATABASE_NAME);
Database db = helper.getWritableDb();
daoSession = new DaoMaster(db).newSession();

@xcy396
Copy link

xcy396 commented Mar 5, 2017

@greenrobot Hello! I have the same problem,with some information below:
Android Studio:2.2.3
device: new Moto X (XT1085) with Android5.1

and in my project build.gradle:

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
    }

in my module build.gradle:

apply plugin: 'org.greenrobot.greendao'

greendao {
    schemaVersion 2
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'org.greenrobot:greendao:3.2.0'
}

Code:

DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(this, "voerka");
        Database database = devOpenHelper.getWritableDb();
        DaoSession mDaoSession = new DaoMaster(database).newSession();

        UserDao userDao = mDaoSession.getUserDao();
        User user = new User(null, "xiaoming", "小明");
        userDao.insert(user);

@Nicknag
Copy link

Nicknag commented Mar 8, 2017

Hi @greenrobot-team

Same here on Samsung Galaxy S7 with Android 7.0 as well as on S3 with Android 6

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
    }
}
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.android.application'

greendao {
    schemaVersion 1
}

[...]

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'org.greenrobot:greendao:3.2.0'
    compile 'org.greenrobot:eventbus:3.0.0'
}

@greenrobot-team
Copy link
Collaborator

If I understand correctly this is not a crash?

This warning should be harmless and is probably caused by ART not being able to load the classes used for database encryption in greenDAO. Unless you are using database encryption and forgot to add the SQLCipher dependency, you should be fine.
-ut

@greenrobot-team greenrobot-team removed their assignment Apr 11, 2017
@ddekanski
Copy link

Dear @greenrobot-team, this warning is not harmless, as it is a false alarm that pollutes the log. It's a lengthy stack trace that makes real problems dissolve in it. Can you please come up with a stub or something that will satisfy ART and stop this from appearing?

@chriscbz
Copy link

@greenrobot It's better to try to deal with this problem amicably

@chriscbz
Copy link

The issue also appears on the Nexus 5X

Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>: java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sqlcipher/database/SQLiteOpenHelper;

@greenrobot-team greenrobot-team changed the title Warning in the first call Avoid EncryptedHelper ART warning due missing SQLCipher super class Aug 1, 2017
@greenrobot-team greenrobot-team changed the title Avoid EncryptedHelper ART warning due missing SQLCipher super class Avoid EncryptedHelper ART warning due to missing SQLCipher super class Aug 1, 2017
@greenrobot-team
Copy link
Collaborator

I just tried to reproduce this on a simple project with an API 25 and API 16 emulator but I am not seeing this message (neither debug or release build). Can you check if you maybe have dependency conflicts by running the androidDependencies task? Does this happen on all versions of Android? -ut

@greenrobot-team greenrobot-team self-assigned this Aug 1, 2017
@greenrobot-team
Copy link
Collaborator

No response. Closing. -ut

@greenrobot-team greenrobot-team removed their assignment Oct 9, 2017
@afunx
Copy link

afunx commented Dec 7, 2017

I encounter the same problem. The reason is some class missing.
Even if you don't use cipher database, if you don't make sqlcipher available, you will face the same problem.
sqlcipher:
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/

gradle just like this:
dependencies {
// greendao
compile 'org.greenrobot:greendao:3.2.2'
// greendao cipher
compile 'net.zetetic:android-database-sqlcipher:3.5.7'
}

@greenrobot-team
Copy link
Collaborator

@Orbyt @Fozei So did you actually try my suggestion to remove any calls to getEncryptedWritableDb(), even if they are protected by a condition?
-ut

@davetao
Copy link

davetao commented Sep 3, 2018

I am also getting these errors and I am not calling getEncryptedWritableDb() Running on Android 9.0

@greenrobot-team
Copy link
Collaborator

@davetao Can you provide a small example project and steps to reproduce this? Because as said before I tried to reproduce this, but can't. So we can not work on a fix. -ut

@Fozei
Copy link

Fozei commented Sep 10, 2018

Indeed, But I can find any calls to getEncryptedWritableDb(), as I did not use it from the beginning. I'd like to provide examples, but I saw others have done that , it will be the same. Even, I'd like to provide you my devices, because I think it is device based, if possible, I mail you my device, I am from China.

@TokenYc
Copy link

TokenYc commented Sep 25, 2018

@greenrobot-team you can reproduce by setting compileSdkVersion and targetSdkVersion to 28 in DaoExample , and then run the app on Virtual Device API 28.

@Lee-Wang-Jing
Copy link

@greenrobot-team you can reproduce by setting compileSdkVersion and targetSdkVersion to 28 in DaoExample with Android Studio 3.2 Version, and then run the app on Virtual Device API 28.100% repetition

@intheworld
Copy link

EncryptedHelper is a non-static inner class of DatabaseOpenHelper,classloader believes non-static class is very important to the Outer one. So classloader tries a lot to load EncryptedHelper, whereas
EncryptedHelper is child of net.sqlcipher.database.SQLiteOpenHelper which can not be found. Then lots of error log is generated, even though you didn't use encrypting.

@YouCii
Copy link

YouCii commented Oct 17, 2018

I got the same problem while running on API 28. We can introduce this library to avoid this problem:
implementation 'net.zetetic:android-database-sqlcipher:3.5.2'

@Fozei
Copy link

Fozei commented Oct 22, 2018

EncryptedHelper is a non-static inner class of DatabaseOpenHelper,classloader believes non-static class is very important to the Outer one. So classloader tries a lot to load EncryptedHelper, whereas
EncryptedHelper is child of net.sqlcipher.database.SQLiteOpenHelper which can not be found. Then lots of error log is generated, even though you didn't use encrypting.

this is the most reasonable explanation, But how to fix it if I did not want to add EncryptedHelper dependency ?

@ezet
Copy link

ezet commented Oct 22, 2018

Same issue. The culprit is the EncryptedHelper as @intheworld mentioned.

@greenrobot-team
Copy link
Collaborator

greenrobot-team commented Nov 13, 2018

Confirmed using example set to compileSdkVersion 28 and targetSdkVersion 28. Thanks everyone!

I/reendao.exampl: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>: java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sqlcipher/database/SQLiteOpenHelper;
I/reendao.exampl:     at void org.greenrobot.greendao.example.App.onCreate() (App.java:16)
I/reendao.exampl:     at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
I/reendao.exampl:     at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:5871)
I/reendao.exampl:     at void android.app.ActivityThread.access$1100(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:199)
I/reendao.exampl:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1650)
I/reendao.exampl:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/reendao.exampl:     at void android.os.Looper.loop() (Looper.java:193)
I/reendao.exampl:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6669)
I/reendao.exampl:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/reendao.exampl:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
I/reendao.exampl:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:858)
I/reendao.exampl: Caused by: java.lang.ClassNotFoundException: Didn't find class "net.sqlcipher.database.SQLiteOpenHelper" on path: DexPathList[[zip file "/data/app/org.greenrobot.greendao.example-_A1h5FuJH1VEvbMes7SvMw==/base.apk"],nativeLibraryDirectories=[/data/app/org.greenrobot.greendao.example-_A1h5FuJH1VEvbMes7SvMw==/lib/x86, /system/lib]]
I/reendao.exampl:     at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
I/reendao.exampl:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
I/reendao.exampl:     at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/reendao.exampl:     at void org.greenrobot.greendao.example.App.onCreate() (App.java:16)
I/reendao.exampl:     at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
I/reendao.exampl:     at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:5871)
I/reendao.exampl:     at void android.app.ActivityThread.access$1100(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:199)
I/reendao.exampl:     at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1650)
I/reendao.exampl:     at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
I/reendao.exampl:     at void android.os.Looper.loop() (Looper.java:193)
I/reendao.exampl:     at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6669)
I/reendao.exampl:     at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/reendao.exampl:     at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:493)
I/reendao.exampl:     at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:858)

-ut

@greenrobot-team
Copy link
Collaborator

#924 gets it down to 2 warnings. Not sure how to get rid of them completely. -ut

Repository owner deleted a comment from omeraslam-citrusbits Feb 26, 2019
@alexfdz
Copy link

alexfdz commented Mar 6, 2019

#924 gets it down to 2 warnings. Not sure how to get rid of them completely. -ut

@greenrobot-team what is the roadmap to merge #924?

@zxyufan
Copy link

zxyufan commented May 20, 2019

Including 'net.zetetic:android-database-sqlcipher' (even you are not using encrypted database) does help you get rid of those warnings, but it also brings a significant APK size increase (from 9.3M to 16.4M in my case). You may need to use 'debugImplementation' if your product is APK size sensitive.

@moxgeek
Copy link

moxgeek commented Jul 11, 2019

i get the same warning in my app
i use to log my logs in a file , to debug them latter
however , the file for maybe 5 seconds become 8Mb .
when i open i found a loop of this
... ... 07-11 17:41:51.927 3814 3814 I package.name: Rejecting re-init on previously-failed class java.lang.Class<org.greenrobot.greendao.database.DatabaseOpenHelper$EncryptedHelper>: java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sqlcipher/database/SQLiteOpenHelper; 07-11 17:41:51.927 3814 3814 I package.name: at void com.example.package.namep.Dao.DaoHelper.onCreate() (DaoHelper.java:94) 07-11 17:41:51.927 3814 3814 I package.name: at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1162) 07-11 17:41:51.927 3814 3814 I package.name: at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6636) 07-11 17:41:51.927 3814 3814 I package.name: at void android.app.ActivityThread.access$2000(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:268) 07-11 17:41:51.927 3814 3814 I package.name: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1995) 07-11 17:41:51.927 3814 3814 I package.name: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:109) 07-11 17:41:51.927 3814 3814 I package.name: at void android.os.Looper.loop() (Looper.java:207) 07-11 17:41:51.927 3814 3814 I package.name: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7539) 07-11 17:41:51.927 3814 3814 I package.name: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2) 07-11 17:41:51.927 3814 3814 I package.name: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:524) 07-11 17:41:51.927 3814 3814 I package.name: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:958) .... ...
i'am not using any Encrypted database , this issus is just on some phones ( in my case huawei phones )
in samsung and Xiaomi there no problem .

@greenrobot-team greenrobot-team added this to the 3.x milestone Jul 16, 2019
@greenrobot-team greenrobot-team modified the milestones: 3.x, 3.3.0 Feb 18, 2020
@greenrobot-team
Copy link
Collaborator

greenrobot-team commented May 4, 2020

3.3.0 has been released which should fix this issue.
https://greenrobot.org/greendao/changelog/

Edit: note that with this fix, the encryption helper is accessed via reflection. If your code uses ProGuard or R8, you will have to update your rules.
https://github.com/greenrobot/greenDAO#r8-proguard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests