nikhilmuz / WhatsApp-Bulk-Sender

Send bulk messages right from your WhatsApp Android Client or WhatsApp Web
MIT License
241 stars 120 forks source link

problem with open db msgstore.db #15

Closed vakora closed 4 years ago

vakora commented 5 years ago

i have a whatsapp 4 business in my phone also have in msgstore.db in /data/data/com.whatsapp.w4b/databases/msgstore.db but when i test app i got a error like this and force close app

2-27 10:11:40.296 19159-19395/ga.nikhilkumar.whatsappsender E/SQLiteLog: (14) cannot open file at line 32456 of [bda77dda96] (14) os_unix.c:32456: (13) open(/data/data/com.whatsapp.w4b/databases/msgstore.db) - 12-27 10:11:40.297 19159-19395/ga.nikhilkumar.whatsappsender E/SQLiteDatabase: Failed to open database '/data/data/com.whatsapp.w4b/databases/msgstore.db'. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:711) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:704) at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:104) at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:100) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 12-27 10:11:40.299 19159-19395/ga.nikhilkumar.whatsappsender E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: ga.nikhilkumar.whatsappsender, PID: 19159 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:325) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:711) at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:704) at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:104) at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:100) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  at java.lang.Thread.run(Thread.java:761)  12-27 10:11:51.179 19159-19182/ga.nikhilkumar.whatsappsender E/EGL_emulation: tid 19182: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)

i already give read/write permission for app whereas i got error

nikhilmuz commented 5 years ago

It requires root access to access WhatsApp database. If your device is rooted and you have given the desired permission, let me know or you may proceed with the non-rooted method for which only accessibility permission is required. P.S. Sending bulk messages by entering the messages in WhatsApp database may lead to blocking of the account. I recommend using non-rooted method till development for the rooted method is getting finished.

vakora commented 5 years ago

i'm testing app on emulator and it is rooted (superuser) screenshot attachet here and i have another question about can you send csv file template for me ? image

nikhilmuz commented 5 years ago

In that case, disable root permission for the app using the superuser app and continue with the non-rooted method or provide me with the logcat of the app at the time of the error.

vakora commented 5 years ago

@nikhilmuz when disable root permission for app (in superuser) app provide error like this:

12-30 01:15:49.626 4113-4113/ga.nikhilkumar.whatsappsender E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ga.nikhilkumar.whatsappsender, PID: 4113
    android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@766865a is not valid; is your activity running?
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:679)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
        at android.widget.Toast$TN.handleShow(Toast.java:434)
        at android.widget.Toast$TN$2.handleMessage(Toast.java:345)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

my friend i have another question about csv template, can you share me csv template that you provide for this app ?

nikhilmuz commented 5 years ago

The sample CSV template is already committed to this repo. Refer readme to get it. If you still face any issue do let me know or try using another phone.

jpage4500 commented 5 years ago

Hi @nikhilmuz - I tried to use this app and also ran into the same SQLiteCantOpenDatabaseException.

My device is rooted (an S5 running Lineage / Android 9 OS). I granted root permission for the app as well.

I verified the file it's looking for exists and made sure the permissions looked OK (using adb shell). Could this be a problem with newer versions of Android preventing 1 app from opening a database that belongs to another app? Since the database call is done outside of the SU() library that's just what jumped out to me.. But, I'd love to hear your thoughts.

(I can run this using AccessibililtyServices -- I'm mostly interested in learning about rooted direct access though)

 (14) cannot open file at line 36921 of [c255889bd9]
 (14) os_unix.c:36921: (13) lstat(/data/data/com.whatsapp.w4b/databases/msgstore.db) - 
 Failed to open database '/data/data/com.whatsapp.w4b/databases/msgstore.db'.
 android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
    at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:212)
    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:503)
    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:204)
    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:196)
    at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:880)
    at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:865)
    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:766)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:783)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:775)
    at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:104)
    at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:100)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
 FATAL EXCEPTION: AsyncTask #1
 Process: ga.nikhilkumar.whatsappsender, PID: 23774
 java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:354)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
 Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
    at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:212)
    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:196)
    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:503)
    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:204)
    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:196)
    at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:880)
    at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:865)
    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:766)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:783)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:775)
    at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:104)
    at ga.nikhilkumar.whatsappsender.sender.WhatsappApi$1.doInBackground(WhatsappApi.java:100)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    ... 4 more
   Force finishing activity ga.nikhilkumar.whatsappsender/.Sender
nikhilmuz commented 5 years ago

@jpage4500 It works on RR (Based on Lineage Oreo) for me. Maybe WhatsApp for business is not installed on your mentioned phone. Check it once. Alternatively, to use it for WhatsApp check for database files in /data/data/com.whatsapp/databases/ instead of /data/data/com.whatsapp.w4b/databases/ and update all the package names accordingly in codes including the internal storage folder hardcoded in the codebase. Also, /data/data/ already have read access unless it's not app specific folder inside it. So, there is no need to call it from shell under the SU library.

jpage4500 commented 5 years ago

@nikhilmuz - I tried with WhatsApp for business. I also tried with the normal WhatsApp version (with modified paths like above).

I verified the paths exist and the SU commands making the folders readable works. I can only think that maybe Android Pie (9) has something that prevents this.

nikhilmuz commented 5 years ago

It maybe the case I will go through android developer change log for the same but I don't think it should be the case. Anyways you may try it with SU access and let me know.

On Sun, 5 May, 2019, 3:45 AM Joe Page, notifications@github.com wrote:

@nikhilmuz https://github.com/nikhilmuz - I tried with WhatsApp for business. I also tried with the normal WhatsApp version (with modified paths like above).

I verified the paths exist and the SU commands making the folders readable works. I can only think that maybe Android Pie (9) has something that prevents this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nikhilmuz/WhatsApp-Bulk-Sender/issues/15#issuecomment-489369668, or mute the thread https://github.com/notifications/unsubscribe-auth/AEZUYFYAUGGUGR3KV7G6GYLPTYDH3ANCNFSM4GMLQ5DA .

jpage4500 commented 5 years ago

I was able to successfully test this using another device, an S5 running OS 5.1.1

For now I am guessing Android 9 prevents opening the database in another app's folder (even if permissions are read/write)

FWIW - this is the line of code I'm talking about:

db = SQLiteDatabase.openOrCreateDatabase(new File("/data/data/com.whatsapp.w4b/databases/msgstore.db"), null);

I even did this test on Android 9 -- I created the File object and logged the full path and if it exists() or not and it reported back 'false'. So, there might not be much that can be done.

I briefly thought maybe you could use SU to copy the database to another location (like the app's) -- modify it -- then use SU to copy it back again.. seems like it could lead to other issues though but might be worth trying as a way to get this to work on OS 9.

sebastian-norena-marquez commented 4 years ago

use Shell.SU.run("chmod -R 777 /data/data/com.whatsapp.w4b/"); for my perfect function

nikhilmuz commented 4 years ago

@jpage4500 Your Idea did work. Thanks for the suggestion and your contribution.