-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassNotFoundException thrown when executing a JavaCommandCapture command #2
Comments
Hello, try following these steps: In Eclipse, right click your project, navigate to "Build Path", then to On Thu, Feb 27, 2014 at 5:12 PM, Jeff Creswell notifications@github.comwrote:
|
Hi Stephen, |
could something going wrong during the construction of anbuild.dex cause this error? I've cleaned the project, removed the old anbuild.dex, rebuilt the project and then anbuild.dex, and re-installed the app but the ClassNotFoundException persists. How can I verify that the contents of anbuild.dex are correct? |
sidenote: OSX creates .DS_Store files in any directory Finder has entered to keep track of metadata for the GUI; if an OSX user has entered $ANDROID_HOME/build-tools with Finder the .DS_Store file will screw up the execution of com.stericson.RootTools.containers.RootClass in the method getPathToDx() which assumes that only relevant SDK version directories will be present. Specifically, a NumberFormatException is thrown from Integer.parseInt("") because split(".") executed on .DS_Store returns the empty string to index 0 of the resultant String array. A workaround is for the user to ensure only relevant SDK version directories are present in build-tools, but some extra validation in RootClass might be handy. Thanks! |
Can there be more than one @RootClass.candidate annotated class in an app using JavaCommandCapture? I looked at the dexdump of my anbuild.dex and I only saw instances of com.stericson.RootTools.containers.RootClass associated with one of my annotations, and not the one I was currently testing in the app which winds up throwing ClassNotFoundException for RootClass |
Hi sorry for only realizing now that we had an issue thread open here. You can use the candidate annotation with multiple classes and they should all end up in the dex file. OK the parseInt() error is goofy I'll fix that (unless Stephen gets around to doing it first) Note that the code you posted is about a private class. This is not a class that can ever be invoked by anyone. |
BTW, beyond the wiki documentation, you can look into a real application: |
In JavaCommandCapture's constructor parameters, what is the significance of the id argument? |
I tried including the RootTools source code with my app build, but the result is the same as above. Below follows the unfiltered logcat history around when I use JavaCommandCapture: [/CODE] Interestingly, since I had to re-root my phone for unrelated reasons and SuperUser had to rewrite its white-list, I got to see that the SuperUser prompt for root permissions does rise for the user to accept or decline when my app tries to use JavaCommandCapture. After pressing 'accept' and seeing the ' has been granted superuser privs' toast the log above gets written. |
and here is the dexdump content of my anbuild.dex file: Class #1 - Class #2 - Class #3 - Class #4 - Class #5 - Class #6 - Class #7 - Class #8 - Class #9 - Class #10 - Class #11 - Class #12 - Class #13 - Class #14 - Class #15 - DelverActivity.RootToolsTest should be the only RootClass.Candidate annotated class in my source. NativeJavaClass is from the RootTools test package. Any ideas would be much appreciated, thanks! |
I also get this error on my Sony Xperia Z2 using the latest Cyanogenmod 11. My Root class is very simple: package com.example.myapp; import com.stericson.RootTools.containers.RootClass; @RootClass.Candidate When I execute this class I also get the error message. Here is my log output: 06-25 11:38:17.167: D/RootTools v3.4(22124): Starting Root Shell! What am I doing wrong? |
I got it working. Was having the same problem. And I had a guess that "since the RootClass isn't found, let's put it into the anbuild.dex" -- and it works. Comment out the AVOIDPATH, and then add annotation for itself. Hack the lookup routine so that it catches itself. |
A better solution:
|
@Fusion Can you confirm whether this is still an open issue or can be closed? |
I followed the directions on the RootTools usage and run Java as root wiki pages, but when I load my app with the following in onCreate() I get a ClassNotFoundException: com.stericson.RootTools.containers.RootClass:
import com.stericson.RootTools.RootTools;
import com.stericson.RootTools.containers.RootClass;
import com.stericson.RootTools.exceptions.RootDeniedException;
import com.stericson.RootTools.execution.CommandCapture;
import com.stericson.RootTools.execution.JavaCommandCapture;
import com.stericson.RootTools.execution.Shell;
...
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
@RootClass.Candidate
private class RootToolsTest{
public RootToolsTest(){
Log.d("RootToolsTest", "testing a Java class run as root");
}
}
The same thing happened when I tried RootTools' test class com.stericson.RootToolsTests.NativeJavaClass. I've tried a number of configurations for the placement and inclusion of the RootTools.jar file (most notably ensuring that the RootTools jar is checked for export and moved to the top of the order and export list in Eclipse) but the ClassNotFoundException persists. The exact logcat output follows:
06-02 07:27:45.529: D/RootTools v3.4(5165): roottools is logging
06-02 07:27:45.529: D/RootTools v3.4(5165): Starting Root Shell!
06-02 07:27:45.539: D/RootTools v3.4(5165): Starting shell: su
06-02 07:27:46.409: D/RootTools v3.4(5165): CommandHandler not created
06-02 07:27:46.429: D/RootTools v3.4(5165): Executing: dalvikvm -cp /data/data
/com.hdradio.fmdelverrooted/files/anbuild.dex com.android.internal.util.WithFramework
com.stericson.RootTools.containers.RootClass
com.hdradio.fmdelver.core.DelverActivity.RootToolsTest
06-02 07:27:46.749: D/Command(5165): ID: 43, java.lang.ClassNotFoundException:
com.stericson.RootTools.containers.RootClass
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.classForName(Native Method)
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.forName(Class.java:217)
06-02 07:27:46.759: D/Command(5165): ID: 43,at java.lang.Class.forName(Class.java:172)
06-02 07:27:46.769: D/Command(5165): ID: 43,at
com.android.internal.util.WithFramework.main(WithFramework.java:36)
06-02 07:27:46.769: D/Command(5165): ID: 43,at dalvik.system.NativeStart.main(Native
Method)
06-02 07:27:46.769: D/Command(5165): ID: 43, Caused by: java.lang.NoClassDefFoundError:
com/stericson/RootTools/containers/RootClass
06-02 07:27:46.769: D/Command(5165): ID: 43, ... 5 more
06-02 07:27:46.769: D/Command(5165): ID: 43, Caused by: java.lang.ClassNotFoundException:
com.stericson.RootTools.containers.RootClass
06-02 07:27:46.769: D/Command(5165): ID: 43,at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-02 07:27:46.769: D/Command(5165): ID: 43,at
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-02 07:27:46.769: D/Command(5165): ID: 43, at
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-02 07:27:46.769: D/Command(5165): ID: 43, ... 5 more
06-02 07:27:46.979: D/RootTools v3.4(5165): Command 43 finished.
My .classpath looks like:
My development system configuration is as follows: OS: Mac OS X 10.9.2 Eclipse: Kepler ADT: 22.3 RootTools Version: 3.4
and my target platform: Android: 4.1.1 Model: Sony Xperia E C1504 (rooted using SRSRoot and the 'Gandalf' exploit) Firmware: Stock Kernel Xperia E C1505_11.3.A.0.47 (supposed to work for C1504 as well)
Any ideas why Android can't find the com.stericson.RootTools.containers.RootClass class?
The text was updated successfully, but these errors were encountered: