Android Studio 3.5 and/or 64bit builds failing

I’m trying to fix a bug that’s been reported with one of our plugins, but seem to be having trouble with the build system within Android Studio and I’ve a hunch this is somehow related to the 64bit support that’s been recently added?

In a nutshell, whatever I do, after Gradle finishes the build and tries to launch my sample app on a connected Android device, the app just flashes open and then closed again, Android Studio times out waiting to see it, and the following error is piped out:

2019-12-10 19:04:09.789 26686-26686/? E/AndroidRuntime: FATAL EXCEPTION: main

    Process: com.mycompany.app, PID: 26686

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.mycompany.app-9s8f8cF8Z13BdIubYCMdXQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.mycompany.app-9s8f8cF8Z13BdIubYCMdXQ==/lib/arm64, /system/lib64]]] couldn’t find "liblua.so"

        at java.lang.Runtime.loadLibrary0(Runtime.java:1012)

        at java.lang.System.loadLibrary(System.java:1669)

        at com.ansca.corona.JavaToNativeShim.<clinit>(JavaToNativeShim.java:141)

        at com.ansca.corona.JavaToNativeShim.useJavaLuaErrorHandler(JavaToNativeShim.java:299)

        at com.ansca.corona.CoronaEnvironment.setLuaErrorHandler(CoronaEnvironment.java:416)

        at com.ansca.corona.CoronaEnvironment.<clinit>(CoronaEnvironment.java:75)

        at com.ansca.corona.CoronaEnvironment.addRuntimeListener(CoronaEnvironment.java:459)

        at com.mycompany.app.CoronaApplication.onCreate(CoronaApplication.java:23)

        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1165)

        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6184)

        at android.app.ActivityThread.access$1300(ActivityThread.java:208)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1785)

        at android.os.Handler.dispatchMessage(Handler.java:106)

        at android.os.Looper.loop(Looper.java:193)

        at android.app.ActivityThread.main(ActivityThread.java:7009)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

The key seems to be the part I’ve highlighted in bold. It’s looking in arm64 / lib64 for liblua.so and failing to find anything?

Googling, I found this: https://medium.com/mobiwise-blog/unsatisfiedlinkerror-problem-on-some-android-devices-b77f2f83837d

He’s talking about abiFilters and useDeprecatedNdk configurations which to be honest just don’t mean anything to me. I’m cautious about hacking away at Gradle files without understanding what I’m doing, and I’m conscious that this article isn’t Corona specific.

Everything I’m finding on Google suggests that this issue started with Android Studio 3.5. I’m currently running 3.5.3 so it’s possible that I was in a 3.4 build the last time this worked. It’s been a while since I did anything to this plugin now.

It’s also possible that this is the first time I’ve tried building since Corona was given 64bit support, though I’m not sure how relative that is with native builds.

Help please =).

So, when we moved to x64, we changed structure of Native project. Please, try copying Native/Project Template/App, drag&dropping App/android on Android studio then running on your device. If it works, I would help you migrating existing project. Also, what OS are you working on?

Ah, that makes sense.

My head isn’t in the same room as me at the moment but I’ll give this a try asap, when I can think properly again, and get back to you.

Thanks!

Finally gotten around to this, and can confirm it’s worked a treat, thanks!

For anybody else stumbling here:

  • I installed the latest daily build, then took a fresh copy of \Native\Project Template\App from within the install directory.

  • Renamed the new template folder to match my original.

  • Replaced \android\plugin\src within the new template, with a copy from my original.

  • Replaced \Corona\main.lua \Corona\config.lua and \Corona\build.settings with my originals.

  • Opened Android Studio and chose to import my project, selecting the \android folder from within the new template.

  • Android Studio processed some Gradle tasks.

  • I then chose File -> Sync Project with Gradle Files and Build -> Clean Project.

  • Connected an Android device, hit Run, and voila, it works.

Thanks again @vlads.

Hello,

We are migrating a MOAI engine project into CORONA Native and we’ve had the same issues.

Could you tell us more about structure changes in 64bit build?

Hello, khanh.dq! Are you using native builds for your project?

Hello,

We are migrating a MOAI engine project into CORONA Native and we’ve had the same issues.

Could you tell us more about structure changes in 64bit build?

Hello, khanh.dq! Are you using native builds for your project?