signalapp / ringrtc

GNU Affero General Public License v3.0
549 stars 135 forks source link

Linking ringrtc build result to signal-android project #29

Closed hilmanfitriana19 closed 3 years ago

hilmanfitriana19 commented 3 years ago

Hello, I tried to build ringrtc manually following the https://github.com/signalapp/ringrtc/blob/master/BUILDING.md file. I then tried changing the ring-rtc dependency in signal-android project at app/build.gradle from implementation 'org.signal:ringrtc-android:2.10.7' to implementation fileTree(dir:'ringrtc-master/out/release/libs', include :['*.jar']).

After that I tried to build and run the application. The build process was successful and the .jar file was registered as external libraries but when it was installed on the device, the program experienced a force close. After looking at the log, it shows that the program failed to load the libringrtc.so library, even though in the file structure, the libringrtc.so library is available and only differs by 1 subfolder.

In the out/release/libs alone I can't find the .aar file and only find .jar .

The following is a log of the errors that appear.

E/AndroidRuntime: FATAL EXCEPTION: main Process: my.new.SignalTesting20, PID: 11912 java.lang.AssertionError: Unable to load ringrtc library at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:346) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0) at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2) at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142) at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253) at android.app.ActivityThread.access$1500(ActivityThread.java:302) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:260) at android.app.ActivityThread.main(ActivityThread.java:8258) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libringrtc.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at org.signal.ringrtc.CallManager.(CallManager.java:76) at org.signal.ringrtc.CallManager.initialize(CallManager.java:91) at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:344) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0)  at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2)  at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142)  at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253)  at android.app.ActivityThread.access$1500(ActivityThread.java:302)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:260)  at android.app.ActivityThread.main(ActivityThread.java:8258)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)  E/SignalUncaughtException: java.lang.AssertionError: Unable to load ringrtc library at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:346) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0) at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2) at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142) at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253) at android.app.ActivityThread.access$1500(ActivityThread.java:302) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:260) at android.app.ActivityThread.main(ActivityThread.java:8258) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libringrtc.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at org.signal.ringrtc.CallManager.(CallManager.java:76) at org.signal.ringrtc.CallManager.initialize(CallManager.java:91) at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:344) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0)  at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2)  at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142)  at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253)  at android.app.ActivityThread.access$1500(ActivityThread.java:302)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:260)  at android.app.ActivityThread.main(ActivityThread.java:8258)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) 

Anybody can help ? Thanks before.

jim-signal commented 3 years ago

Hi, the build document is only a step towards publishing and will be updated to be more clear. For local building and testing, this is the recommended approach:

$ OVERRIDE_VERSION=2.10-my-version ./bin/build-aar --install-local

The install-local is key, it will create the .aar file in ~/.m2/repository/org/signal/ringrtc-android/2.10-my-version. The version given is just an example, you can use anything, but make sure it is unique so as not to clash with official published versions.

Then, you can change the Signal-Android's project at app/build.gradle from implementation 'org.signal:ringrtc-android:2.10.7' to implementation 'org.signal:ringrtc-android:2.10-my-version'. It should pick up the local copy when building (you might need to rebuild). Also for local testing, you might need to remove the ringrtc entry from the app/witness-verifications.gradle file.

Note that the build-aar script can be used instead of calling make android. It also accepts other command line options such as:

hilmanfitriana19 commented 3 years ago

Thanks @jim-signal for the recommended approach.

hilmanfitriana19 commented 3 years ago

hello again @jim-signal, after following the suggested approach, I'm still having trouble getting the signal-android project to run on android. So far, I have tried some source code including master branch and v.2.10.7 tag but I can't find the .aar file. Even in the ~/.m2/repository/org folder there is no signal folder. The application itself was successfully built but immediately force closed when it was run on Android. Before running the build-aar command I just ran the prepare-workspace command and added local.properties to publish/android. Is there a step that I'm wrong or missed?

hilmanfitriana19 commented 3 years ago

There is one similar progress found, I saved libringrtc.jar and libwebrtc.jar in app/libs folder in Signal-android project. Then I added all the other files in the out/release/libs folder containing .so files for various architectures into the app/src/main/jniLibs file. The application was successfully built but still force close when opened on Android. I then found a new error. E/AndroidRuntime: FATAL EXCEPTION: main Process: com.application.SignalTestingUbuntu, PID: 9396 java.lang.AssertionError: Unable to load ringrtc library at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:346) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0) at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2) at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142) at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253) at android.app.ActivityThread.access$1500(ActivityThread.java:302) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:260) at android.app.ActivityThread.main(ActivityThread.java:8258) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libringrtc_rffi.so" not found: needed by /data/data/com.application.SignalTestingUbuntu/code_cache/.overlay/base.apk/lib/arm64-v8a/libringrtc.so in namespace classloader-namespace at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at org.signal.ringrtc.CallManager.<clinit>(CallManager.java:76) at org.signal.ringrtc.CallManager.initialize(CallManager.java:91) at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:344) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0)  at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2)  at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142)  at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253)  at android.app.ActivityThread.access$1500(ActivityThread.java:302)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:260)  at android.app.ActivityThread.main(ActivityThread.java:8258)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)  I/JobDatabase: onOpen() E/SignalUncaughtException: java.lang.AssertionError: Unable to load ringrtc library at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:346) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0) at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2) at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142) at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253) at android.app.ActivityThread.access$1500(ActivityThread.java:302) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:260) at android.app.ActivityThread.main(ActivityThread.java:8258) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006) Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libringrtc_rffi.so" not found: needed by /data/data/com.application.SignalTestingUbuntu/code_cache/.overlay/base.apk/lib/arm64-v8a/libringrtc.so in namespace classloader-namespace at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at org.signal.ringrtc.CallManager.<clinit>(CallManager.java:76) at org.signal.ringrtc.CallManager.initialize(CallManager.java:91) at org.thoughtcrime.securesms.ApplicationContext.initializeRingRtc(ApplicationContext.java:344) at org.thoughtcrime.securesms.ApplicationContext.lambda$QaXC_yGYxWOey7BnguyExwrBRyw(Unknown Source:0)  at org.thoughtcrime.securesms.-$$Lambda$ApplicationContext$QaXC_yGYxWOey7BnguyExwrBRyw.run(Unknown Source:2)  at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:142)  at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:178)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7253)  at android.app.ActivityThread.access$1500(ActivityThread.java:302)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2144)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:260)  at android.app.ActivityThread.main(ActivityThread.java:8258)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

The error change from unable to load libringrtc.so to 'library "libringrtc_rffi.so" not found`. Is there anything that i should do ?

jim-signal commented 3 years ago

Hi, I am not sure of the build issue here yet, but I am still looking. Even without --install-local you should still be seeing gradle create the aar file(s) here: out/gradle/outputs/aar/

Do you see any aar file there now?

Yes, both the libringrtc.so and libringrtc_rffi.so libraries should be in the aar file. Somehow you are getting the libringrtc.so in there it seems.

hilmanfitriana19 commented 3 years ago

Thanks again @jim-signal . As you mentioned, I found the .aar file in the out/gradle/outputs/aar folder.

This really helped me and solved both linking and access private library issues in my project. When using libringrtc.jar in the previous project's dependecy, I encountered an error that required adding the .so file manually to the project's android signal and other errors regarding access to private libraries.