Fixed: Fix proguard removing JNI used methods for release builds

```
Exception in createServerSocketNative():
java.lang.NoSuchMethodError: no non-static method "Lcom/termux/shared/jni/models/JniResult;.<init>(IILjava/lang/String;I)V"
	at com.termux.shared.net.socket.local.LocalSocketManager.createServerSocketNative(Native Method)
	at com.termux.shared.net.socket.local.LocalSocketManager.createServerSocket(LocalSocketManager.java:125)
	at com.termux.shared.net.socket.local.LocalServerSocket.start(LocalServerSocket.java:100)
	at com.termux.shared.net.socket.local.LocalSocketManager.start(LocalSocketManager.java:84)
	at com.termux.shared.shell.am.AmSocketServer.start(AmSocketServer.java:68)
	at com.termux.shared.termux.shell.am.TermuxAmSocketServer.start(TermuxAmSocketServer.java:101)
	at com.termux.shared.termux.shell.am.TermuxAmSocketServer.setupTermuxAmSocketServer(TermuxAmSocketServer.java:77)
	at com.termux.app.TermuxApplication.onCreate(TermuxApplication.java:53)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6719)
	at android.app.ActivityThread.access$1300(ActivityThread.java:237)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7664)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
```
This commit is contained in:
agnostic-apollo
2022-04-20 02:08:58 +05:00
parent 53f26c9659
commit 7f7d889dd0
2 changed files with 4 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package com.termux.shared.jni.models;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import com.termux.shared.logger.Logger;
@@ -11,6 +12,7 @@ import com.termux.shared.logger.Logger;
* https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html
* https://developer.android.com/training/articles/perf-jni
*/
@Keep
public class JniResult {
/**

View File

@@ -2,6 +2,7 @@ package com.termux.shared.net.socket.local;
import android.content.Context;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import com.termux.shared.android.ProcessUtils;
@@ -10,6 +11,7 @@ import com.termux.shared.logger.Logger;
import com.termux.shared.markdown.MarkdownUtils;
/** The {@link PeerCred} of the {@link LocalClientSocket} containing info of client/peer. */
@Keep
public class PeerCred {
public static final String LOG_TAG = "PeerCred";