ndarilek / tts-rs

115 stars 26 forks source link

Unable to successfully run the Android example for tts-rs. #55

Open mzdk100 opened 6 months ago

mzdk100 commented 6 months ago

I cloned the latest tts-rs and opened tts rs/examples/android using IntelliJ IDEA. After clicking "Run", an error occurred:

AndroidRuntime          pid-30765                            E  FATAL EXCEPTION: main
                                                                Process: rs.tts, PID: 30765
                                                                java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{rs.tts/rs.tts.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "rs.tts.MainActivity" on path: DexPathList[[zip file "/data/app/~~B-wOeNZbu9ABdP5z-uMpUQ==/rs.tts-MwtIDebz15srfv5yRxuPlA==/base.apk"],nativeLibraryDirectories=[/data/app/~~B-wOeNZbu9ABdP5z-uMpUQ==/rs.tts-MwtIDebz15srfv5yRxuPlA==/lib/arm64, /system/lib64, /system_ext/lib64]]
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3806)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4049)
                                                                    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
                                                                    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                                                                    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                    at android.os.Looper.loopOnce(Looper.java:211)
                                                                    at android.os.Looper.loop(Looper.java:300)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:8348)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
                                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "rs.tts.MainActivity" on path: DexPathList[[zip file "/data/app/~~B-wOeNZbu9ABdP5z-uMpUQ==/rs.tts-MwtIDebz15srfv5yRxuPlA==/base.apk"],nativeLibraryDirectories=[/data/app/~~B-wOeNZbu9ABdP5z-uMpUQ==/rs.tts-MwtIDebz15srfv5yRxuPlA==/lib/arm64, /system/lib64, /system_ext/lib64]]
                                                                    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
                                                                    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
                                                                    at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
                                                                    at android.app.Instrumentation.newActivity(Instrumentation.java:1359)
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3791)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4049) 
                                                                    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) 
                                                                    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                                                                    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) 
                                                                    at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                    at android.os.Looper.loopOnce(Looper.java:211) 
                                                                    at android.os.Looper.loop(Looper.java:300) 
                                                                    at android.app.ActivityThread.main(ActivityThread.java:8348) 
                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) 
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028) 
mzdk100 commented 6 months ago

Then I guessed that the MainActivity.kt file was not compiled, so I modified the build.gradle file:

plugins {
    id "com.android.application"
    id "org.mozilla.rust-android-gradle.rust-android"
    id "org.jetbrains.kotlin.android"
}
...

Add the line id "org.jetbrains.kotlin.android" to the file, and then run the above error to disappear, but encounter the following error:

AndroidRuntime          rs.tts                               D  Shutting down VM
AndroidRuntime          rs.tts                               E  FATAL EXCEPTION: main
                                                                Process: rs.tts, PID: 32745
                                                                java.lang.UnsatisfiedLinkError: dlopen failed: library "libhello_world.so" not found
                                                                    at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
                                                                    at java.lang.Runtime.loadLibrary0(Runtime.java:998)
                                                                    at java.lang.System.loadLibrary(System.java:1661)
                                                                    at rs.tts.MainActivity.<clinit>(MainActivity.kt:8)
                                                                    at java.lang.Class.newInstance(Native Method)
                                                                    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
                                                                    at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
                                                                    at android.app.Instrumentation.newActivity(Instrumentation.java:1359)
                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3791)
                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4049)
                                                                    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
                                                                    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                                                                    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                    at android.os.Looper.loopOnce(Looper.java:211)
                                                                    at android.os.Looper.loop(Looper.java:300)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:8348)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
Process                 rs.tts                               I  Process is going to kill itself!
                                                                java.lang.Exception
                                                                    at android.os.Process.killProcess(Process.java:1330)
                                                                    at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:195)
                                                                    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
                                                                    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
                                                                    at java.lang.Thread.dispatchUncaughtException(Thread.java:2306)
mzdk100 commented 6 months ago

This time I checked tts-rs/examples/android/app/build/rustJniLibs and found that this folder is empty. What should I do? Can we use cargo-apk to build it? Because I think cargo-app is better to use.