Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Trying to login caused crash, Didn't find class "org.apache.http.client.methods.HttpPost" #5000

Closed
noamraph opened this issue Sep 30, 2018 · 3 comments
Assignees
Labels
Accepted Maintainers welcome a PR implementing this feature Bug

Comments

@noamraph
Copy link

noamraph commented Sep 30, 2018

Reproduction Steps
  1. Run master (a5ac35e) from Android studio
  2. Click the "sync" button
  3. Enter your login details
Expected Result

Login

Actual Result

Exception

Debug info
09/30 16:26:51: Launching AnkiDroid
No apk changes detected since last installation, skipping installation of /home/noam/sand/Anki-Android/AnkiDroid/build/outputs/apk/debug/AnkiDroid-debug.apk
$ adb shell am force-stop com.ichi2.anki
$ adb shell am start -n "com.ichi2.anki/com.ichi2.anki.IntentHandler" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.ichi2.anki.tests | com.ichi2.anki
Waiting for application to come online: com.ichi2.anki.tests | com.ichi2.anki
Waiting for application to come online: com.ichi2.anki.tests | com.ichi2.anki
Connecting to com.ichi2.anki
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8608', transport: 'socket'
I/chatty: uid=10085(com.ichi2.anki) identical 6 lines
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1412)
W/System.err: java.io.FileNotFoundException: /jacoco.exec (Read-only file system)
W/System.err:     at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:308)
W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
        at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
        at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
W/System.err:     at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
        at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
W/System.err:     at com.ichi2.anki.AnkiDroidApp.$jacocoInit(Unknown Source:13)
        at com.ichi2.anki.AnkiDroidApp.<clinit>(Unknown Source:0)
W/System.err:     at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
        at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:49)
W/System.err:     at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1061)
W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5842)
        at android.app.ActivityThread.access$1100(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/ACRA: ACRA is disabled for com.ichi2.anki, initializing...
I/AnkiDroid: Creating notification channel with id/name: General Notifications/AnkiDroid
I/CompatV26: Creating notification channel with id/name: Synchronization/Synchronization
I/CompatV26: Creating notification channel with id/name: Global Reminders/Cards due
I/CompatV26: Creating notification channel with id/name: Deck Reminders/Reminders
I/WebViewFactory: Loading com.android.chrome version 66.0.3359.158 (code 336015817)
I/com.ichi2.anki: The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader: Time to load native libraries: 4 ms (timestamps 8080-8084)
I/chromium: [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader: Expected native library version number "66.0.3359.158", actual native library version number "66.0.3359.158"
I/CollectionHelper: openCollection: /storage/emulated/0/AnkiDroid/collection.anki2
D/Collection: [1538314015] Collection.java:<init>(): /storage/emulated/0/AnkiDroid/collection.anki2,  2.9alpha36
V/IntentHandler: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.ichi2.anki/.IntentHandler }
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@9b0ead2
D/DeckPicker: onCreate()
W/com.ichi2.anki: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/com.ichi2.anki: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
W/com.ichi2.anki: Accessing hidden method Landroid/widget/PopupWindow;->setClipToScreenEnabled(Z)V (light greylist, reflection)
W/com.ichi2.anki: Accessing hidden method Landroid/widget/PopupWindow;->setEpicenterBounds(Landroid/graphics/Rect;)V (light greylist, reflection)
D/BackupManager: performBackup: No backup necessary due to no collection changes
D/DeckPicker: onResume()
D/DialogHandler: Reading persistent message
D/DeckPicker: Refreshing deck list
D/OpenGLRenderer: HWUI GL Pipeline
D/DeckTask: doInBackgroundLoadDeckCounts
D/DeckTask: enabling garbage collection of mPreviousTask...
D/AnkiStatsTaskHandler$DeckPreviewStatistics: Starting DeckPreviewStatistics
    DeckPreviewStatistics query: select count(), sum(time)/1000 from revlog where id > 1538294400000
D/: HostConnection::get() New Host Connection established 0xd51d07c0, tid 9019
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
    android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xe6ea9560: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
W/com.ichi2.anki: Accessing hidden method Landroid/graphics/drawable/DrawableContainer;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, reflection)
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
D/DeckPicker: onCreateOptionsMenu()
I/DeckPicker: DeckPicker:: Sync button pressed
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
I/chatty: uid=10085(com.ichi2.anki) RenderThread identical 2 lines
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
D/OpenGLRenderer: endAllActiveAnimators on 0xd52ce780 (RippleDrawable) with handle 0xd526d1f0
D/DeckPicker: onPause()
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@a3d7886
W/AnkiActivity: Couldn't preload url: https://ankiweb.net/account/register
D/DialogHandler: Reading persistent message
D/EGL_emulation: eglMakeCurrent: 0xe6ea9560: ver 2 0 (tinfo 0xe6e90920)
D/DeckPicker: onStop()
D/WidgetStatus: WidgetStatus.update(): already running or not enabled
D/UIUtils: saveCollectionInBackground: start
D/DeckTask: doInBackgroundSaveCollection
D/UIUtils: saveCollectionInBackground: finished
D/DeckTask: enabling garbage collection of mPreviousTask...
I/AssistStructure: Flattened final assist data: 4896 bytes, containing 1 windows, 16 views
I/AssistStructure: Flattened final assist data: 4968 bytes, containing 1 windows, 16 views
D/MyAccount: loginListener.onPreExcecute()
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4
    Process: com.ichi2.anki, PID: 8986
    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: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost;
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:209)
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:148)
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:143)
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:133)
        at com.ichi2.libanki.sync.RemoteServer.hostKey(RemoteServer.java:50)
        at com.ichi2.async.Connection.doInBackgroundLogin(Connection.java:210)
        at com.ichi2.async.Connection.doOneInBackground(Connection.java:193)
        at com.ichi2.async.Connection.doInBackground(Connection.java:186)
        at com.ichi2.async.Connection.doInBackground(Connection.java:53)
        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) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.methods.HttpPost" on path: DexPathList[[zip file "/data/app/com.ichi2.anki-fK2sUndor-gTbJOxJNBVpA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ichi2.anki-fK2sUndor-gTbJOxJNBVpA==/lib/x86, /data/app/com.ichi2.anki-fK2sUndor-gTbJOxJNBVpA==/base.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:209) 
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:148) 
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:143) 
        at com.ichi2.libanki.sync.HttpSyncer.req(HttpSyncer.java:133) 
        at com.ichi2.libanki.sync.RemoteServer.hostKey(RemoteServer.java:50) 
        at com.ichi2.async.Connection.doInBackgroundLogin(Connection.java:210) 
        at com.ichi2.async.Connection.doOneInBackground(Connection.java:193) 
        at com.ichi2.async.Connection.doInBackground(Connection.java:186) 
        at com.ichi2.async.Connection.doInBackground(Connection.java:53) 
        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) 
I/ACRA: ACRA is disabled for com.ichi2.anki - forwarding uncaught Exception on to default ExceptionHandler
I/Process: Sending signal. PID: 8986 SIG: 9
Disconnected from the target VM, address: 'localhost:8608', transport: 'socket'
Research

Enter an [ x ] character to confirm the points below:

[x ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ x] I have checked the manual and the FAQ and could not find a solution to my issue

[ x] I have searched for similar existing issues here and on the user forum

mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 30, 2018
This starts the process of exercising HTTP features
prior to any contemplated move to OkHttp. More
importantly it makes sure basic HTTP works to guard against
things like issue ankidroid#5000
mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 30, 2018
@mikehardy
Copy link
Member

Nice - that's a good one. Thanks for attempting to work on this from source, and thanks for reporting this.

As we move towards API28 we have to be very careful of Apache HTTP library use as they are deprecating it:

https://developers.google.com/maps/documentation/android-sdk/config#specify_requirement_for_apache_http_legacy_library

I just broke this with this commit moving us to API28 - I had focused on the hidden API issues with API28 and neglected a part of the Apache HTTP library changes.

The correct fix (building now in my CI) is to follow the API docs and add an entry to the AndroidManifest.

The full fix is to also implement at least a basic exercise of the HTTP infrastructure in automated tests so something fundamental like this doesn't slip through - and my PR has that also.

I'll have it merged as soon as CI checks out and I re-read the diff a few more times

@mikehardy mikehardy self-assigned this Sep 30, 2018
@mikehardy mikehardy added Bug Accepted Maintainers welcome a PR implementing this feature labels Sep 30, 2018
@mikehardy
Copy link
Member

If you have a moment - can you confirm this was running against an API28 device? In my testing I trigger it every time on my API28 emulator, but on API<27 it doesn't appear to be necessary

mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 30, 2018
mikehardy added a commit that referenced this issue Sep 30, 2018
This starts the process of exercising HTTP features
prior to any contemplated move to OkHttp. More
importantly it makes sure basic HTTP works to guard against
things like issue #5000
@noamraph
Copy link
Author

noamraph commented Oct 1, 2018

@mikehardy

If you have a moment - can you confirm this was running against an API28 device? In my testing I trigger it every time on my API28 emulator, but on API<27 it doesn't appear to be necessary

Yes, I confirm it was an API28 emulator. I also confirm that it now works fine.

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Accepted Maintainers welcome a PR implementing this feature Bug
Projects
None yet
Development

No branches or pull requests

2 participants