Android - Could not find class ... referenced from - android

I'm writing my 4th year project and I am trying to add an external library but for some reason I can't seem to get this running. I have been Googling for days and I still can't seem to fix this problem.
I have tried the following:
1) I have added the jar file to the "libs" folder
2) I have added the jar file as a library
3) I've checked the library off in the "Build Path" > "Order and Export"
Anyone else have any possible suggestions?
dalvikvm(4015) : Could not find class 'org.ejml.data.DenseMatrix64F', referenced from method com.makarintosh.voweltutor.FormantTracker.findRoots
dalvikvm(4015) : VFY: unable to resolve new-instance 805 (Lorg/ejml/data/DenseMatrix64F;) in Lcom/makarintosh/voweltutor/FormantTracker;
dalvikvm(4015) : DexOpt: unable to opt direct call 0x17e3 at 0x05 in Lcom/makarintosh/voweltutor/FormantTracker;.findRoots
AndroidRuntime(4015) : at com.makarintosh.voweltutor.FormantTracker.findRoots(FormantTracker.java:157)
AndroidRuntime(4015) : at com.makarintosh.voweltutor.FormantTracker.doLPC(FormantTracker.java:122)
AndroidRuntime(4015) : at com.makarintosh.voweltutor.Recorder.processData(Recorder.java:61)
AndroidRuntime(4015) : at com.makarintosh.voweltutor.Recorder$1.run(Recorder.java:80)
The library I am trying to add is this:
https://code.google.com/p/efficient-java-matrix-library/
EDIT
I also forgot to mention that the error seems to occur only with the specified class, "DenseMatrix64F". Although other classes that I am using from the library seem to run just fine.
The error occurs during RUNTIME.

First, you need to Read the Liberary manual because it is the best reference for your liberary
You have two ways in Android to add liberaries. First, to add a liberary project from Project>Preferences(Properties)> Android> Add Liberary project. Second to have a .Jar file and copy it into your project in Libs directory.
Sometimes you need to Clean and Build the project again after importing your liberary.
Look for this link and examples for your lib, it will help https://code.google.com/p/efficient-java-matrix-library/wiki/EjmlManual

Related

Android project complaining "The type bolts.Task cannot be resolved. It is indirectly referenced from required .class files"

I'm trying to go through the Parse Mealspotting tutorial, but after adding the Parse library I'm getting weird errors. I've found other similar errors while googling, but nothing that has worked. Here's one. I also read to look at Adding the Support Libraries, but that didn't fix it.
Exact text is:
Multiple markers at this line
- The type bolts.Task cannot be resolved. It is indirectly referenced from required .class files
- The class file Task<?> contains a signature 'Ljava/util/Set<Lbolts/Task<*>.TaskCompletionSource;>;' ill-formed at
position 30
I don't care about the support libraries or what devices the app will work on, all I want is for this to work so I can go through the tutorial. Has anyone dealt with this before?
I have also tried creating a project that only supports Kit Kat and removed the support libraries, but it's still throwing the same error.
Try to add the bolts-android-1.1.3 lib in your project. You can find it in the Parse SDK zip file.
First, be sure that you have the Parse library in your lib folder.
I had the same problem and solved it by adding the bolts-android-1.1.3.jar (right click on your project properties and then java build path , tab libraries, add jars or externals jars) that i found in Parse-1.7.1.
Then clean your project and it should work.

how to resolve Link error with BaseGameUtility when building Android project

I am trying to use Google Play Games Services with my android project. I have followed instructions as both seen on the official documentation and here as well: http://helios.hud.ac.uk/u1070589/blog/?p=202
Both libraries BaseGameUtils and google-play-services_lib are added and referenced by my project. BaseGameUtils references google-play-services_lib.
All boxes are checked under Properties -> Java Build Path -> Order and Export.
I receive the following error when attempting to run:
Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
I don't understand the issue. I have followed the instructions exactly. And retried several times.
Any ideas?
I had to go into the Java Build Path and remove BaseGameUtils and google-play-services_lib from there.
Also to remove another error I had to go into the libraries section and add the two jars (basegameutils.jar and google-play-services.jar.)
I'm not sure why this last part was nowhere in the instructions but this fixed the problem.

import lib google.android.gms "Could not find class" after updating sdk and google-api

I use google-play-services_lib for one project but after upgrading the google api and sdk,
I get these errors :
05-21 01:57:55.813: E/dalvikvm(22721): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method com.eloges.services.GeoLocService$2.onLocationChanged
or this :
05-21 01:57:55.823: E/AndroidRuntime(22721): FATAL EXCEPTION: main
05-21 01:57:55.823: E/AndroidRuntime(22721): java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.CircleOptionsCreator
I read this questions : Issue with Google Maps Android Api v2
but, I tested "google-play-services_lib" on another project and I don't have these errors...
So I concluded that, my error come from my project.
I copied and imported again my project, with right click(Properties>Library >Add etc....) like on another project where it works... but I still have these errors where it can come from?
to "solve" my problem, I created a new project and I copied my java files and xml files.
If someone already had this problem without creating a new project like me..., I'm interested in the solution.
Right-click on the project, under Build Path, select Configure Build Path, select the Order and Export tab and check the relevant lib. Had the same issue with the support library today.

Why do I get Link of class failed importing a jar into an Android project in Eclipse?

In Eclipse I wrote a package of classes for use with Android and tested them in an android project, keeping the test code in a second package. Then I used the command line to create a jar file from all the casses in my project's bin/classes directory (just for my library package, not the test package).Running "jar tf" shows all the classes correctly prefixed with my package name.
I then created another Android project with an activity that imported my first package and used the methods, like this:
import uk.me.stevewaring.nestedsettings.NestedSettingsCommon;
import uk.me.stevewaring.nestedsettings.NestedSettingsReformat;
public class ShowNestedSettings extends Activity implements NestedSettingsReformat
{...
I then right clicked on my new project and used Build Path to add my jar. My jar shows at the top of the java build path under Libraries, and at the bottom under Order and Export.
Once I added my jar, all the red squiggly lines from lint complaining about the methods in my package vanished.
However when I try to debug my project, in the LogCat I get:
04-27 05:45:44.180: I/dalvikvm(14576): Failed resolving Lcom/example/shownestedsettings/ShowNestedSettings; interface 553 'Luk/me/stevewaring/nestedsettings/NestedSettingsReformat;'
04-27 05:45:44.210: W/dalvikvm(14576): Link of class 'Lcom/example/shownestedsettings/ShowNestedSettings;' failed
and then the run fails because the class to run does not exist.
When I built the original project, I did not tick the box "Mark this project as a library", could that be what the problem is? I'm not sure what effect that check box has. If that is the problem, is there any way to retrospectively apply that action, or would I have to create a complete new project and copy my package into it before using it to create a jar. If that is not the problem, then what have I done wrong?
Further information:
I removed the implementation of the interface, then when I tried to debug, I received this:
04-27 05:52:10.919: I/dalvikvm(14677): Could not find method uk.me.stevewaring.nestedsettings.NestedSettingsCommon.initialise, referenced from method com.example.shownestedsettings.ShowNestedSettings.onCreate
04-27 05:52:10.949: W/dalvikvm(14677): VFY: unable to resolve static method 3566: Luk/me/stevewaring/nestedsettings/NestedSettingsCommon;.initialise (Landroid/app/Activity;)V
04-27 05:52:10.949: D/dalvikvm(14677): VFY: replacing opcode 0x71 at 0x0003
which did not surprise me, NestedSettingsCommon.initialise was the first call my activity made to code in my Jar.
I also tried exporting the Jar from in Eclipse instead of making it from the command line. That made no difference either.
Make sure the JAR is set to be exported with the application:
Project > Properties > Java Build Path > Order and Export

Using Android library in eclipse and jumping to class files instead of source file that is within eclipse workspace

I found this bug http://code.google.com/p/android/issues/detail?id=20731 that is resolved but it did not fix this exactly, but I see in comments that this is mentioned there as problem. Is there some way in eclipse to setup dependencies in project somehow , that I will be able to normally jump to source when I am in eclipse editor ? I tried numerous ways to solve this.
My setup is:
Android project that has Android Library setup in Android>Library
Android Library project that is within workspace and have dependency on Java library project
Java Library project that is within workspace and is opened as class file instead of source !!!
Including java library project through build path normally (this is causing build to fail)
[2012-03-13 11:07:21 - Taxicar Driver Android] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lrensoft/java/collections/GenericIterator;
[2012-03-13 11:07:21 - Taxicar Driver Android] Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2012-03-13 11:07:21 - Taxicar Driver Android] Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
Not including , project runs ok , but editor is jumping to library class files.
Note that I have to include Android Library project through build path , even though it runs ok without it (it is enough to set is as dependent android library) , but when I remove it I get also those files as class files :) .
So I think that right way is not including projects through build path at all but how then setup project to jump to source ?
I had a similar problem - Open Declaration command would bring up the .class file instead of the .java file. My problem however was occurring when I would use Open Declaration in my Android app project to goto some source in my Android Library project. By following some instructions from a comment on this blog post Eclipse now takes me to the .java file (instead of the .class file) when I use the Open Declaration command.
The instructions are:
Right click on your project, select Properties
Select Java Build Path page
Select Order and Export tab
Select each library project your project depends on, and use Top or Up to move it above the projects outputs. Eg. move all library projects to the top.
That fixed the goto .java instead of .class file issue for me.
(Unfortunately though, after making these changes, this issue appears (at least it did for me): Could not find Library.apk!)
I then setup my workspace as you describe in your question (Android App depends on Android Library project depends on Java Library project) I find that Open Declaration is always taking me to .java files, so it all appears to be working ok in this respect.
Refactoring
I tried to refactor a method which is defined in a class in the Android Library. A popup with a "problem" of
Binary references to a refactored element have been found. They will
not be updated, which may lead to problems if you proceed.
However after pressing Continue the refactoring took place without any issues.
I then tried to refactor a method which is defined in a class in the Java Library. I didn't get any popups this time, and the refactoring worked.
The java library aspect might just work these days because the bugs you guys mentioned have been fixed... (I am using Eclipse 4.2.0 with ADT 20.0.3). I thought I would add this answer however incase it helps someone out with issues of Open Declaration jumping to .class instead of .java file.
I found solution. I have to create Android library from my java library as well and then include it as android library as well as Java library , Then I have to reorder build path export items so Android "Library Projectsā€¯ are last . And well not much work, Now even rename refactoring works , with some warning but works :) , Well I am happy developer again.

Categories

Resources