ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.56k stars 2.22k forks source link

Test failure running Java 10 with current master (on macOS Mojave at least) #5088

Closed mikehardy closed 4 years ago

mikehardy commented 5 years ago
Reproduction Steps
  1. git clone current master onto an macOS Mojave machine (may affect all operating systems)
  2. make sure JDK10 is the current JVM (java -fullversion)
  3. run tests ./gradlew clean test --parallel
Expected Result

All unit tests pass

Actual Result

Something like the snippet below.

Note that using JDK1.8 / Java 8 works fine - but Java 10 should work (and used to work?). I'll bisect the recent changes when I get a chance to figure out what happened, in the meantime this will hopefully serve as fair warning for people

> Task :AnkiDroid:testDebugUnitTest
Calling mockable JAR artifact transform to create file: /Users/mike/.gradle/caches/transforms-1/files-1.1/android.jar/99f6ab42a3152c7375c17c91a490f09f/android.jar with input /Users/mike/Library/Android/sdk/platforms/android-28/android.jar
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.robolectric.util.ReflectionHelpers$8 (file:/Users/mike/.gradle/caches/modules-2/files-2.1/org.robolectric/shadowapi/4.0.1/cbc93117c17bd18a060f4bd78b3c447cc3605cb3/shadowapi-4.0.1.jar) to method java.lang.ClassLoader.getPackage(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.robolectric.util.ReflectionHelpers$8
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

com.ichi2.anki.DeckPickerTest > verifyCodeMessages FAILED
    java.lang.NoClassDefFoundError
        Caused by: java.lang.ClassNotFoundException
            Caused by: java.lang.IllegalArgumentException

com.ichi2.anki.DeckPickerTest > verifyBadCodesNoMessage FAILED
    java.lang.NoClassDefFoundError

com.ichi2.anki.AnalyticsTest > testSendException FAILED
    java.lang.NullPointerException at AnalyticsTest.java:85

31 tests completed, 3 failed

> Task :AnkiDroid:testDebugUnitTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':AnkiDroid:testDebugUnitTest'.
> There were failing tests. See the report at: file:///Users/mike/work/AnkiDroid/Anki-Android/AnkiDroid/build/reports/tests/testDebugUnitTest/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 47s
mikehardy commented 5 years ago

Irritatingly it is the addition of robolectric in commit 60659f1b98a4f64f7e09d2084dffc439239c7272

I'm fine with JDK8 but I pay attention to forward-porting blockers. There is some work upstream to demonstrate the failure, hopefully resulting in a fix - https://github.com/robolectric/deckard/pull/121

mikehardy commented 5 years ago

This is still failing, but after upgrading to current Robolectric, the failure has migrated to an error with the PKCS store as initialized from OkHTTP in the Google Analytics dependency.

java.lang.NullPointerException: No password supplied for PKCS#12 KeyStore.
        at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source)
        at java.base/java.security.KeyStore.load(KeyStore.java:1479)
        at java.base/sun.security.ssl.TrustStoreManager$TrustAnchorManager.loadKeyStore(TrustStoreManager.java:367)
        at java.base/sun.security.ssl.TrustStoreManager$TrustAnchorManager.getTrustedCerts(TrustStoreManager.java:315)
        at java.base/sun.security.ssl.TrustStoreManager.getTrustedCerts(TrustStoreManager.java:59)
        at java.base/sun.security.ssl.TrustManagerFactoryImpl.engineInit(TrustManagerFactoryImpl.java:51)
        at java.base/javax.net.ssl.TrustManagerFactory.init(TrustManagerFactory.java:278)
        at okhttp3.internal.Util.platformTrustManager(Util.java:666)
        at okhttp3.OkHttpClient.<init>(OkHttpClient.java:257)
        at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1040)
        at com.brsanthu.googleanalytics.httpclient.OkHttpClientImpl.createHttpClient(OkHttpClientImpl.java:78)
        at com.brsanthu.googleanalytics.httpclient.OkHttpClientImpl.<init>(OkHttpClientImpl.java:36)
        at com.ichi2.anki.analytics.UsageAnalytics.initialize(UsageAnalytics.java:65)
        at com.ichi2.anki.AnalyticsTest.setUp(AnalyticsTest.java:101)

Attempting to switch to the Conscrypt library may fix it but was unsuccessful (and also would likely add more weight to the .apk)

adamwolf commented 5 years ago

@mikehardy do we want to close this?

mikehardy commented 5 years ago

I'd like to leave it open though the Priority-Low tag is correct. I don't see why using JDKs > 8 just to compile should fail, and eventually I'll puzzle it out (or someone else will)

adamwolf commented 5 years ago

I'm on OpenJDK 11 and it builds fine for me here on 10.14, but I might not be tracking 100% of what you're saying either :)

On Wed, Sep 18, 2019 at 9:29 AM Mike Hardy notifications@github.com wrote:

I'd like to leave it open though the Priority-Low tag is correct. I don't see why using JDKs > 8 just to compile should fail, and eventually I'll puzzle it out (or someone else will)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ankidroid/Anki-Android/issues/5088?email_source=notifications&email_token=AAAIWYM5RLROM5DCCPWHD6LQKI3K5A5CNFSM4GBRM5PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7AIKSY#issuecomment-532710731, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAIWYLBDUBHIWJUTQSMD4LQKI3K5ANCNFSM4GBRM5PA .

mikehardy commented 5 years ago

Hmm - I just checked the release cadence for JDKs and it looks like JDK10 was a non-LTS version (long term support) and is already sunsetted, so perhaps the issue (and build matrix for .travis.yml) should move to JDK11, and as long as that passes (seems like it would according to you?) then yeah, we can close