1

I use Process to run command line instruction.

When I run an instruction, application will show "I/System﹕ exec(MY_INSTRUCTIONS)" on logcat.

But because I'm developing a private SDK for other people, so I must disable the messages on logcat.

My code looks like:

String[] command = {"ls", "-rf"};
ProcessBuilder pb = new ProcessBuilder(command);
try {
    Process process = pb.start();
} catch (IOException e) {
    e.printStackTrace();
}

And the logcat message looks like:

I/System﹕ exec(ls -rf @ com.mypackage.MainActivity.cli:152)

I know the proguard can remove all the log message, but disable "android.util.Log" message could not correctly disable this system message.

Please help me to disable this logcat message or remove the messages by proguard.

Morshues
  • 125
  • 1
  • 12
  • you need to remove logcat messages ? – Murtaza Khursheed Hussain Aug 17 '15 at 08:20
  • I want to let this message no longer show on logcat anymore. – Morshues Aug 17 '15 at 08:26
  • Maybe there is another way to do what you are trying to do without ProcessBuilder. You can certainly do that command with Pure Java and not need ProcessBuilder at all. – Yepher Aug 17 '15 at 12:48
  • @Yepher I used `Runtime.getRuntime().exec("MY_INSTRUCTIONS")` to do the same thing, but I got the same logs. Could you give me another way to do this? – Morshues Aug 17 '15 at 14:28
  • If your command is ("ls", "-rf") than you can use File and look through the files in the directory. See http://stackoverflow.com/a/5694398/1733038 – Yepher Aug 17 '15 at 21:35
  • @Yepher `ls -rf` is just an example to represent for my privileges SDK, I don't need to look through the files path. – Morshues Aug 18 '15 at 01:15
  • You have not given any hint at what you do need to do that requires interaction at command line so I doubt anyone can help. Without any more details all I can say is your best bet is to do what you need to do in Java or native and not use Runtime commands.. – Yepher Aug 18 '15 at 12:20

1 Answers1

1

In proguard you can add these enteries

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** w(...);
    public static *** v(...);
    public static *** i(...);
}
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83