DraggableGridView can't be included in project - android

I am trying to include thquinn's DraggableGridView into my project. I followed all the instructions given there for getting started including these steps for adding a jar to my project. (DraggableGridView.jar is showing as a referenced library.)
It compiles correctly, but when run my project I get the following error in Logcat:
I/dalvikvm(798): Could not find method com.animoto.android.views.DraggableGridView.addView, referenced from method com.example.GuessWhat.GuessWhat.loadImages
W/dalvikvm(798): VFY: unable to resolve virtual method 11: Lcom/animoto/android/views/DraggableGridView;.addView (Landroid/view/View;)V
D/dalvikvm(798): VFY: replacing opcode 0x6e at 0x003a
E/dalvikvm(798): Could not find class 'com.animoto.android.views.DraggableGridView', referenced from method com.example.GuessWhat.GuessWhat.onCreate
W/dalvikvm(798): VFY: unable to resolve check-cast 15 (Lcom/animoto/android/views/DraggableGridView;) in Lcom/example/GuessWhat/GuessWhat;
D/dalvikvm(798): VFY: replacing opcode 0x1f at 0x0023
D/AndroidRuntime(798): Shutting down VM
W/dalvikvm(798): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
E/AndroidRuntime(798): FATAL EXCEPTION: main
E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.GuessWhat/com.example.GuessWhat.GuessWhat}: android.view.InflateException: Binary XML file line #3: Error inflating class com.animoto.android.views.DraggableGridView
E/AndroidRuntime(798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
E/AndroidRuntime(798): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime(798): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime(798): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime(798): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(798): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(798): at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime(798): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(798): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
Here's my import:
import com.animoto.android.*;
In my activity I have:
DraggableGridView dgv = ((DraggableGridView) findViewById(R.id.dgv));
ImageView iv = new ImageView(getApplicationContext());
iv.setImageDrawable(new BitmapDrawable(Images[index]));
dgv.addView(iv);
The last line is where the build error is. What am I missing?

First of all, as Eclipse can resolve your dependency but Dalvik cannot, it seems that the library wasn't bundled with your application. The typical cause of this is adding your library as a normal Java dependency into /lib, whereas building for Android expects the jar in /libs. See also this question.
Secondly, looking at the source, it appears that your import is not specified correctly. DraggableGridView's qualified name is com.animoto.android.views.DraggableGridView.
Your activity should declare the import as:
import com.animoto.android.views.DraggableGridView;

Related

Cannot deploy my apps since updating SDK tools today [duplicate]

This question already has answers here:
Libraries do not get added to APK anymore after upgrade to ADT 22
(7 answers)
Closed 9 years ago.
This morning I updated various SDK components from Eclipse. I think it was
- Android SDK or Platform tools
- Google APIs 17 update
- Android Support Library
- Google Play Services
Now, my apps won't deploy. They build ok (eventually, after an hour of reconfiguring and rebuilding) but now when I deploy to the device, I get the following:
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
Unable to resolve superclass of Lcom/com/myapp/MainActivity; (81)
Link of class 'Lcom/com/myapp/MainActivity;' failed
VFY: replacing opcode 0x71 at 0x0006
VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
Unable to resolve superclass of Lcom/com/myapp/MainActivity; (81)
Link of class 'Lcom/com/myapp/MainActivity;' failed
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40015560)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.MainActivity}: java.lang.ClassNotFoundException: com.myapp.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.myapp.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.MainActivity in loader dalvik.system.PathClassLoader[/data/app/myapp.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
... 11 more
Bear in mind that this project, and others, have been happily running for months, so this isn't just some daft error like the activity missing from the manifest file.
I'm really wishing I hadn't bothered with the update now... any ideas welcome!
I faced this issue couple of days before.
Right click your project, Go to properties->Java Build path->Order and Export
Check Android Private Library->Click Ok
Clean the project and run it.it will work.
sdk\extras\android\support\v4 inside there is a jar file android-support-v4.jar add this to the external jars

I am unable to access the library file JFUGUE.jar in eclipse android app

My android Project on playing piano music, so i added jfugue.jar to my project.
my java code is:
line no:29 Player player=new Player();
line no:30 player.play("C D E F G A B");
the above code is written in button onclick listener. when i am clicking on that button i got RunTimeEexception, as below:
02-25 09:20:54.062: W/dalvikvm(846): VFY: unable to find class referenced in signature (Ljavax/sound/midi/Sequencer;)
02-25 09:20:54.082: I/dalvikvm(846): Could not find method javax.sound.midi.MidiSystem.getSequencer, referenced from method org.jfugue.Player.<init>
02-25 09:20:54.082: W/dalvikvm(846): VFY: unable to resolve static method 3600: Ljavax/sound/midi/MidiSystem;.getSequencer (Z)Ljavax/sound/midi/Sequencer;
02-25 09:20:54.082: D/dalvikvm(846): VFY: replacing opcode 0x71 at 0x0011
02-25 09:20:54.092: W/dalvikvm(846): VFY: unable to find exception handler at addr 0x1c
02-25 09:20:54.102: W/dalvikvm(846): VFY: rejected Lorg/jfugue/Player;.<init> (Z)V
02-25 09:20:54.102: W/dalvikvm(846): Verifier rejected class Lorg/jfugue/Player;
02-25 09:20:54.122: D/AndroidRuntime(846): Shutting down VM
02-25 09:20:54.122: W/dalvikvm(846): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
02-25 09:20:54.152: E/AndroidRuntime(846): FATAL EXCEPTION: main
02-25 09:20:54.152: E/AndroidRuntime(846): java.lang.VerifyError: org/jfugue/Player
02-25 09:20:54.152: E/AndroidRuntime(846): at com.example.xyz.MainActivity$1.onClick(MainActivity.java:29)
I never used jFugue, but it looks like your problem is that Android doesn't implement javax.sound.midi. So you need to find/develop an implementation of this package.
Here are some options discussed: A simple free MIDI implementation in Java besides javax.sound.midi: Are there any?
Where have you inserted your jar file.?
Also please check if you have build the jar file.

Why is android.util.LruCache.* not found when using android-support-v4?

I am writing a project that uses LruCache, which is included in the android-support-v4.jar compat library. When running on devices with JB, the code works fine, but when I run it on my Droid X with GB, the app dies with the following errors:
I/dalvikvm(2459): Could not find method android.util.LruCache.put, referenced from method blah.blah.Utility.getBitmap
W/dalvikvm(2459): VFY: unable to resolve virtual method 2641: Landroid/util/LruCache;.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0026
... [repeats similar lines] ...
W/dalvikvm(2459): Unable to resolve superclass of Lblah/blah/Utility$1; (353)
W/dalvikvm(2459): Link of class 'Lblah/blah/Utility$1;' failed
E/dalvikvm(2459): Could not find class 'blah.blah.Utility$1', referenced from method blah.blah.Utility.initCaches
W/dalvikvm(2459): VFY: unable to resolve new-instance 559 (Lblah/blah/Utility$1;) in Lblah/blah/Utility;
D/dalvikvm(2459): VFY: replacing opcode 0x22 at 0x000d
D/dalvikvm(2459): VFY: dead code 0x000f-002c in Lblah/blah/Utility;.initCaches (ILandroid/content/Context;)V
I/dalvikvm(2459): Could not find method android.util.LruCache.get, referenced from method blah.blah.Utility.mCacheGet
W/dalvikvm(2459): VFY: unable to resolve virtual method 2640: Landroid/util/LruCache;.get (Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0008
D/dalvikvm(2459): VFY: dead code 0x000b-000e in Lblah/blah/Utility;.mCacheGet (Ljava/lang/String;)Landroid/graphics/Bitmap;
... [repeats similar lines] ...
D/AndroidRuntime(2459): Shutting down VM
W/dalvikvm(2459): threadid=1: thread exiting with uncaught exception (group=0x40018560)
E/AndroidRuntime(2459): FATAL EXCEPTION: main
E/AndroidRuntime(2459): java.lang.NoClassDefFoundError: blah.blah.Utility$1
E/AndroidRuntime(2459): at blah.blah.Utility.initCaches(Utility.java:49)
E/AndroidRuntime(2459): at blah.blah.MainActivity.onCreate(MainActivity.java:40)
... [etc] ...
W/ActivityManager(1318): Force finishing activity blah.blah/.MainActivity
Utility.java:49 looks like this:
mCache = new LruCache<String, Bitmap>( mCacheSize ) // <-- line 49 --
{
#Override
protected int sizeOf( String key, Bitmap bitmap )
{
return bitmap.getByteCount();
}
};
So everywhere I referenced LruCache or its methods causes an error. The first thing that comes to mind is that android-support-v4.jar was somehow left out of the APK file, but that doesn't look like the case. I've placed the jar file under libs/, and checking classes.dex.d after running ant debug, I see that it has added the following line:
/home/paul/workspace/blah/libs/android-support-v4.jar \
My second thought was that maybe LruCache isn't in android-support-v4, but looking at the source I see that the following source file is in there, and that it has the methods I am trying to use:
/home/paul/bin/android-sdk/extras/android/support/v4/src/java/android/support/v4/util/LruCache.java
So why isn't it found?
The classes in the support library use a different namespace.
You need to import:
import android.support.v4.util.LruCache;
or alternatively you can copy & compile LruCache.java directly into your app.

Unable to find classes in Android library file

I have created a very simple Android app just to work with functionality. Within the app I would like to call a web service client to retrieve and display some data. I think I have succesfully imported and referenced the jar file (i.e. library). It appears to be instantiating the class successfully but when that class is referencing another class within the jar/library it throws a class not found error. Any ideas??? Anything else I can provide to help answer???
Here is my code:
package mhcs.android.ehd;
import mhcs.services.client.EHD.EHDClient;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class GetTicketDescription extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
EHDClient client = new EHDClient();
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String title = getString(R.string.title);
setTitle(title); // done so that we can change the default title
//get handles to editText and button widgets
final EditText eText = (EditText) findViewById(R.id.editText1);
final Button button = (Button) findViewById(R.id.button1);
eText.setText(client.getTicketDescription("MMLZ-8LVRMK"));
button.setOnClickListener(new Button.OnClickListener(){
#Override
public void onClick(View v) {
//get the String entered into the editText widget
CharSequence editText = eText.getText();
//display the toast
Toast.makeText(GetTicketDescription.this, editText, Toast.LENGTH_LONG).show();
}
});
}
}
Here is the error:
D/dalvikvm(538): Not late-enabling CheckJNI (already on)
I/dalvikvm(538): threadid=3: reacting to signal 3
I/dalvikvm(538): Wrote stack traces to '/data/anr/traces.txt'
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
E/dalvikvm(538): Could not find class 'org.tempuri.EHDLookupService', referenced from method mhcs.services.client.EHD.EHDClient.<init>
W/dalvikvm(538): VFY: unable to resolve new-instance 93 (Lorg/tempuri/EHDLookupService;) in Lmhcs/services/client/EHD/EHDClient;
D/dalvikvm(538): VFY: replacing opcode 0x22 at 0x0003
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
I/dalvikvm(538): Could not find method org.tempuri.EHDLookupService.getBasicHttpBindingIEHDLookupService, referenced from method mhcs.services.client.EHD.EHDClient.<init>
W/dalvikvm(538): VFY: unable to resolve virtual method 112: Lorg/tempuri/EHDLookupService;.getBasicHttpBindingIEHDLookupService ()Lorg/tempuri/IEHDLookupService;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x001c
W/dalvikvm(538): VFY: unable to find class referenced in signature (Ljavax/xml/bind/JAXBElement;)
I/dalvikvm(538): Could not find method javax.xml.bind.JAXBElement.getValue, referenced from method mhcs.services.client.EHD.EHDClient.getAssigneeTickets
W/dalvikvm(538): VFY: unable to resolve virtual method 42: Ljavax/xml/bind/JAXBElement;.getValue ()Ljava/lang/Object;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x0026
W/dalvikvm(538): VFY: unable to find class referenced in signature (Ljavax/xml/bind/JAXBElement;)
I/dalvikvm(538): Could not find method javax.xml.bind.JAXBElement.getValue, referenced from method mhcs.services.client.EHD.EHDClient.getTicketDescription
W/dalvikvm(538): VFY: unable to resolve virtual method 42: Ljavax/xml/bind/JAXBElement;.getValue ()Ljava/lang/Object;
D/dalvikvm(538): VFY: replacing opcode 0x6e at 0x000b
W/dalvikvm(538): Unable to resolve superclass of Lorg/tempuri/EHDLookupService; (73)
W/dalvikvm(538): Link of class 'Lorg/tempuri/EHDLookupService;' failed
D/dalvikvm(538): DexOpt: unable to opt direct call 0x006b at 0x15 in Lmhcs/services/client/EHD/EHDClient;.<init>
D/AndroidRuntime(538): Shutting down VM
W/dalvikvm(538): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
E/AndroidRuntime(538): FATAL EXCEPTION: main
E/AndroidRuntime(538): java.lang.NoClassDefFoundError: org.tempuri.EHDLookupService
E/AndroidRuntime(538): at mhcs.services.client.EHD.EHDClient.<init>(EHDClient.java:25)
E/AndroidRuntime(538): at mhcs.android.ehd.GetTicketDescription.onCreate(GetTicketDescription.java:15)
E/AndroidRuntime(538): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(538): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime(538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime(538): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime(538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime(538): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(538): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(538): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(538): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(538): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(538): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(538): threadid=3: reacting to signal 3
I/dalvikvm(538): Wrote stack traces to '/data/anr/traces.txt'
Note: I understand the issue with org/tempuri and will correct.
(Can't post image of my workspace as I am a new user)
Find Properties -> Java Build Path -> Order and Export
Change Android Dependencies order
Try to create a new folder called libs under your project and put the .jar file there...
I had the same problem, I tried to mark the Android Private Libraries under Order and Export and it didn't work for me. Then I noticed that my libs folder wasn't referenced under the Java Build Path. So I just added it to Libraries and it worked.
Go to
Project> Build Path >Configure Build Path
Check the Libraries you wanted and hit ok

Dalvik mess with library code and project cannot runs anymore

After updating ADT and Android SDK on my machine, all my projects get errors.
Now I have this:
PS: This error happens when running the project that have a jar as dependency (it was compiled with proguard and we dont have the original sourcecode to compile it again).
W/dalvikvm(3497): VFY: unable to resolve static field 994 (storeicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0042
W/dalvikvm(3497): VFY: unable to resolve static field 987 (libraryicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0060
W/dalvikvm(3497): VFY: unable to resolve static field 1069 (mainframe) in Lcom/ww/dgs/R$layout;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x00b1
I/dalvikvm(3497): DexOpt: unable to optimize static field ref 0x0467 at 0x16 in Lcom/ww/sharedlibrary/e;.a
D/AndroidRuntime(3497): Shutting down VM
W/dalvikvm(3497): threadid=1: thread exiting with uncaught exception (group=0x400f8760)
E/AndroidRuntime(3497): FATAL EXCEPTION: main
E/AndroidRuntime(3497): java.lang.NoClassDefFoundError: com.ww.dgs.R$layout
E/AndroidRuntime(3497): at com.ww.mainframe.MainFrame.onCreate(Unknown Source)
E/AndroidRuntime(3497): at com.ww.iba.DigiMag.onCreate(DigiMag.java:27)
E/AndroidRuntime(3497): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
E/AndroidRuntime(3497): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
E/AndroidRuntime(3497): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
E/AndroidRuntime(3497): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
E/AndroidRuntime(3497): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
E/AndroidRuntime(3497): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(3497): at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(3497): at android.app.ActivityThread.main(ActivityThread.java:4028)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime(3497): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(3497): threadid=4: reacting to signal 3
I/dalvikvm(3497): Wrote stack traces to '/data/anr/traces.txt'
The code from com.ww is inside a jar that I used on the other builds.
I am getting this too now and am able to get around it by removing all external jars from the project. You can add them back in after it's been cleaned. I'm assuming you have access to the original project source code...
Rightclick on project, go to Java Build Path, and remove all external jars other than your Android libs. Then clean.
Got this error after updating to the Android Platform Tools preview 15 rc5 and Android Tools 21 rc5, plus running the "check for updates..." in eclipse.
LogCat error
java.lang.NoClassDefFoundError: com.someapplicationlibrary.lib.R$layout
Eclipse compiler error:
Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'myApplication'.
String index out of range: -51
Errors running builder 'Android Pre Compiler' on project 'someapplicationlibrary'.
String index out of range: -54
Tried to revert to the stabel Android Tools... but ending up with even more errors.
My solution was to load the workspace in a eclipse version that was not updated with the "check for updates..." in the eclipse Help menu.
Then it compiled correct, and the application worked again, hope this helps:)

Categories

Resources