From 7f7d889dd0fa53cd35408a09b9c5686f3602d152 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Wed, 20 Apr 2022 02:08:58 +0500 Subject: [PATCH] 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;.(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) ``` --- .../src/main/java/com/termux/shared/jni/models/JniResult.java | 2 ++ .../main/java/com/termux/shared/net/socket/local/PeerCred.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/termux-shared/src/main/java/com/termux/shared/jni/models/JniResult.java b/termux-shared/src/main/java/com/termux/shared/jni/models/JniResult.java index 34c38a8feb..3621f9f3a6 100644 --- a/termux-shared/src/main/java/com/termux/shared/jni/models/JniResult.java +++ b/termux-shared/src/main/java/com/termux/shared/jni/models/JniResult.java @@ -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 @@ * 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 { /** diff --git a/termux-shared/src/main/java/com/termux/shared/net/socket/local/PeerCred.java b/termux-shared/src/main/java/com/termux/shared/net/socket/local/PeerCred.java index 8adab1f7e1..6674eee0f7 100644 --- a/termux-shared/src/main/java/com/termux/shared/net/socket/local/PeerCred.java +++ b/termux-shared/src/main/java/com/termux/shared/net/socket/local/PeerCred.java @@ -2,6 +2,7 @@ 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.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";