Java As Root , executing a class - Not found error
i finally managed to build the anbuild.dex with AndroidStudio
but when i run the JavaCommand
it outputs ( not found ) , as if its executing the class as string in the command line
Shell shell;
try {
shell = RootShell.getShell(true);
JavaCommand cmd = new JavaCommand(
43,
false,
MainActivity.this,
runclass.class.getName()) {
@Override
public void commandOutput(int id, String line) {
Log.v("aaaaa",line);
//visualUpdate(TestHandler.ACTION_DISPLAY, line + "\n");
super.commandOutput(id, line);
}
};
shell.add(cmd);
} catch (Exception e) {
e.printStackTrace();
}
Dumb question: do you install the file? Something like...
public class Prepare {
public static boolean setup(Context context) {
try {
InputStream is = context.getAssets().open("anbuild.dex");
FileOutputStream fos = context.openFileOutput("anbuild.dex", Context.MODE_PRIVATE);
byte[] buffer = new byte[4096];
int readCount;
while(-1 != (readCount = is.read(buffer))) {
fos.write(buffer, 0, readCount);
}
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
}
Also, what is the output of runclass.class.getName()?
i have manually copied the anbuild.dex to res/raw folder
is that enough?
can you explain the code you mentioned ? and should i use it ?
the output of the runclass.class.getName() , is the com.example.test.runclass
after checking the JavaCommand and Command classes , i dont find anything that checks if im executing JavaCommand not a Command , thats why it takes the class name as a command instead of executing it the JavaCommand Class , only sets the JavaCommand Value to true and Command class doesn't consider this at all and never use it
after searching the internet , i found an old version of the Command class that has the getCommand method inside the Command Class thatchecking the JavaCommand boolean value if its true , it works something else
here is what and found
public String getCommand() {
StringBuilder sb = new StringBuilder();
if(javaCommand) {
String filePath = context.getFilesDir().getPath();
for (int i = 0; i < command.length; i+) {
if(i > 0)
{
sb.append('\n');
}
/*
* TODO Make withFramework optional for applications
* that do not require access to the fw. -CFR
*/
sb.append(
"dalvikvm -cp " filePath "/anbuild.dex"
+ " com.android.internal.util.WithFramework"
+ " com.stericson.RootTools.containers.RootClass "
+ command[i]);
}
}
else {
for (int i = 0; i < command.length; i+) {
if(i > 0)
{
sb.append('\n');
}
sb.append(command[i]);
}
}
return sb.toString();
}
while on the real source code on github , the code is
public final String getCommand() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < command.length; i++) {
if (i > 0) {
sb.append('\n');
}
sb.append(command[i]);
}
return sb.toString();
}
can be there an update to make RootClass run perfectly with AndroidStudio ???
also (com.android.internal.util.WithFramework) is not removed from Android M and higher