Could not find method XXX, referenced from method YYY
I have two android projects, ProjA requires ProjB (in Eclipse Properties > Java Build Path > Projects > Add > ProjB). Every thing compiles ok in Eclipse, but when I run ProjA I get an error:
Could not find method XXX, referenced from method YYY.
Where XXX - is the method from ProjB.
How c开发者_运维百科an I fix the settings?
I have a similar problem when using external jar (in my case openCSV). The reason I had a problem was due to a change in ADT 17 (or above). What I needed to do to resolve the problem was
- In Eclipse go to Properties -> Java build path -> Order and export.
- Mark my jar.
- Move jar to top of the list.
The solution was found in the following page which reference to a very good article.
Importing Class from External Jar, Android you can try the above link.. I suggest taking care of this "android only support 1.6 and not 1.7" in your library jar
Combine the two projects into one.
Or, have ProjB build a JAR file that ProjA includes.
Or, turn ProjB into a remote Service, with the method in question exposed via AIDL, and have ProjA bind to that service to use the method.
You may want to look at your design, if you don't want to go with the answer by CommonsWare.
For example, you could call the second project from the first by using Intents, for example.
If there is code that is common to the two projects then you may want to pull that into a new project where you can include the files directly into both projects, but if the two are supposed to work together there are different ways in Android to allow Activities to call each other, or to pass information, and you may want to look at those.
I've experienced this problem with the new Android Gradle build system, I fixed it by running gradle clean
and then building and installing again. Build systems are complex beasts and Google still has yet to solve the dependency problem perfectly.
精彩评论