Android native modules won't initialise on upgrading 32->33

Hi folks,

Just upgraded an existing ejected app from sdk 32 to sdk 33. Most things work, but our native module won’t work, and running it under Android Studio it seems like the whole native module system is failing because there’s a bad reference to the old expolib_v1 package inside expoview there:

I/org.project: Rejecting re-init on previously-failed class java.lang.Class<host.exp.exponent.network.ExponentNetwork$5>: java.lang.NoClassDefFoundError: Failed resolution of: Lexpolib_v1/okhttp3/Interceptor;
I/org.project:     at void host.exp.exponent.di.NativeModuleDepsProvider.<init>(android.app.Application) (NativeModuleDepsProvider.java:59)
$ ag expolib_v1 node_modules
node_modules/expokit/maven/host/exp/exponent/expoview/33.0.0/ivy-33.0.0.xml
297:    <dependency org="expolib_v1.com.squareup.okhttp3" name="okhttp" rev="3.6.0" conf="compileOnly-&gt;default"/>
298:    <dependency org="expolib_v1.com.squareup.okhttp3" name="okhttp-urlconnection" rev="3.6.0" conf="compileOnly-&gt;default"/>
299:    <dependency org="expolib_v1.com.squareup.okio" name="okio" rev="1.13.0" conf="compileOnly-&gt;default"/>

I’ve tried using expo 33.0.4 and 33.06 but there’s no difference. Full log output is below. Any ideas would be very welcome!

I/org.project: Rejecting re-init on previously-failed class java.lang.Class<host.exp.exponent.network.ExponentNetwork$5>: java.lang.NoClassDefFoundError: Failed resolution of: Lexpolib_v1/okhttp3/Interceptor;
I/org.project:     at void host.exp.exponent.di.NativeModuleDepsProvider.<init>(android.app.Application) (NativeModuleDepsProvider.java:59)
        at void host.exp.exponent.di.NativeModuleDepsProvider.initialize(android.app.Application) (NativeModuleDepsProvider.java:80)
        at void host.exp.expoview.Exponent.<init>(android.content.Context, android.app.Application) (Exponent.java:134)
        at void host.exp.expoview.Exponent.initialize(android.content.Context, android.app.Application) (Exponent.java:116)
        at void host.exp.exponent.ExpoApplication.onCreate() (ExpoApplication.java:77)
        at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
        at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6209)
        at void android.app.ActivityThread.access$1200(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:236)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1784)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:214)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7037)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:494)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:965)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "expolib_v1.okhttp3.Interceptor" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/base.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_dependencies_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_resources_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_0_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_1_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_2_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_3_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_4_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_li
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void host.exp.exponent.di.NativeModuleDepsProvider.<init>(android.app.Application) (NativeModuleDepsProvider.java:59)
        at void host.exp.exponent.di.NativeModuleDepsProvider.initialize(android.app.Application) (NativeModuleDepsProvider.java:80)
        at void host.exp.expoview.Exponent.<init>(android.content.Context, android.app.Application) (Exponent.java:134)
        at void host.exp.expoview.Exponent.initialize(android.content.Context, android.app.Application) (Exponent.java:116)
        at void host.exp.exponent.ExpoApplication.onCreate() (ExpoApplication.java:77)
        at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
        at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6209)
        at void android.app.ActivityThread.access$1200(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:236)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1784)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:214)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7037)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:494)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:965)
I/org.project: Rejecting re-init on previously-failed class java.lang.Class<host.exp.exponent.network.ExponentNetwork$5>: java.lang.NoClassDefFoundError: Failed resolution of: Lexpolib_v1/okhttp3/Interceptor;
        at void host.exp.exponent.di.NativeModuleDepsProvider.<init>(android.app.Application) (NativeModuleDepsProvider.java:59)
        at void host.exp.exponent.di.NativeModuleDepsProvider.initialize(android.app.Application) (NativeModuleDepsProvider.java:80)
        at void host.exp.expoview.Exponent.<init>(android.content.Context, android.app.Application) (Exponent.java:134)
        at void host.exp.expoview.Exponent.initialize(android.content.Context, android.app.Application) (Exponent.java:116)
        at void host.exp.exponent.ExpoApplication.onCreate() (ExpoApplication.java:77)
        at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
        at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6209)
        at void android.app.ActivityThread.access$1200(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:236)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1784)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:214)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7037)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:494)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:965)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "expolib_v1.okhttp3.Interceptor" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/base.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_dependencies_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_resources_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_0_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_1_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_2_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_3_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_lib_slice_4_apk.apk", zip file "/data/app/our.org.project-YdMquLVO0CAs77F004kUQA==/split_li
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
        at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
        at void host.exp.exponent.di.NativeModuleDepsProvider.<init>(android.app.Application) (NativeModuleDepsProvider.java:59)
        at void host.exp.exponent.di.NativeModuleDepsProvider.initialize(android.app.Application) (NativeModuleDepsProvider.java:80)
        at void host.exp.expoview.Exponent.<init>(android.content.Context, android.app.Application) (Exponent.java:134)
        at void host.exp.expoview.Exponent.initialize(android.content.Context, android.app.Application) (Exponent.java:116)
        at void host.exp.exponent.ExpoApplication.onCreate() (ExpoApplication.java:77)
        at void android.app.Instrumentation.callApplicationOnCreate(android.app.Application) (Instrumentation.java:1154)
        at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6209)
        at void android.app.ActivityThread.access$1200(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:236)
        at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1784)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
        at void android.os.Looper.loop() (Looper.java:214)
        at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7037)
        at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
        at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:494)
        at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:965)

Hi @igorclark how did you go with that issue?
I am updating from 33 -> 34 and I am stuck on the same problem.
Any help would be highly appreciated :slight_smile:

There may have been some changes to the app/build.gradle file (and possibly others). I’d recommend ejecting a fresh project and comparing the gradle files (and other config files in the android folder) from that with yours. If you take that route, you actually might as well go all the way to Expo 36.

Thanks for the advise. Unfortunately the project we maintain is pretty big so the transition from 33 -> 36 is bit too hectic (too many breaking changes - too risky)

That’s why we try to go:
1.) from 33 -> 34 (so far no success, weird issue with expolib_v1)
2.) from 34 -> 35 (so far no luck when jumping from 33 to 35, issues with some expo-* native modules)
3.) from 35 -> 36 (did’t try yet)

You know your stuff best, but I was just saying, as someone who has done those upgrades, basically every time I upgraded, I hand-checked all the core project files against a freshly ejected blank project. Sometimes, I copied my code and modifications to those projects and started fresh instead. At least on the Android side, I can assure you, that, by the time you get to 36, you will have turned over a huge chunk of gradle and other files. Just 35 to 36 includes changing half of your dependencies to AndroidX versions. As you upgrade to 34/ 35, you might end up putting in shims to fix things expecting AndroidX, only to rip those shims out in 36. 35 adds a bunch of external Expo deps, like you noticed- that’s another one where sometimes its better to just copy from a fresh project.

1 Like

Yeah, you are probably right. I think we will go with your advise and consider moving directly to 36.
In that case maybe we will avoid doing some thing twice. thank @llamaluvr
I will post some observations once we sort this out.

In case you guys struggle with random missing libs or very weird related lib issue the best what you could do is to take fresh expo’s (version you upgrading to) gradle.build and other generated files that you modify in your project and compare side by side with your current project.

We were migrating from:

  • 33 to 34 - no luck (plenty of weird issues)
  • 34 to 35 - no luck (plenty of weird issues)

Then we compared fresh gradle.build with the one we currently have and we discovered a lot of differences. After updating our gradle.build, settings.gradle etc… the project finally build and is working.

When comparing side by side, the fresh expo files are base on which you should try to apply your project’s customisations.

Hi @pozoor, I’m afraid I gave up. The app I was working on was running in a kiosk-style environment, so it was possible to lock all the dependencies to the previous version and just not bother with the update. I recommend doing what @llamaluvr suggests, 33->34 didn’t really work out for me but I think that although it’s going to be fiddly, that’s the way to go.

yeah, I thought for a moment you could end up like that :wink:
Expo is making it really easy sometimes…
Anyhow thanks for the answer @igorclark