Note that there are some explanatory texts on larger screens.

plurals
  1. POGallery View Source Not Found Error
    text
    copied!<p>I am a very early android and java beginner. I have noticed a very strange error in a simple Gallery view I have made. I have 7 pictures to scroll between. Here is the strange part though. Only pic 1, 2 and part of 3 are visible when you first open the app. When I try to scroll to pic 4 and up (The ones that are not visible when you open the emulator) it gives me an error that reads: Source Not Found. The JAR file has no source. Again, this only happens If I try to scroll to anything above pic3. Here is my main.xml file code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" tools:context=".GalleryActivity" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Images of San Francisco" /&gt; &lt;Gallery android:id="@+id/gallery1" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;ImageView android:id="@+id/image1" android:layout_width="320dp" android:layout_height="250dp" android:scaleType="fitXY" /&gt; </code></pre> <p></p> <p>Here is for attrs.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;declare-styleable name="Gallery1"&gt; &lt;attr name="android:galleryItemBackground" /&gt; &lt;/declare-styleable&gt; &lt;/resources&gt; </code></pre> <p>And finaly, this is my java file.</p> <pre><code> package net.learn2develop.Gallery; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import android.view.Menu; public class GalleryActivity extends Activity { //---the images to display--- Integer[]imageIDs = { R.drawable.pic1, R.drawable.pic2, R.drawable.pic4, R.drawable.pic5, R.drawable.pic6, R.drawable.pic7 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Gallery gallery = (Gallery) findViewById(R.id.gallery1); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(getBaseContext(), "pic" + (position + 1) + " selected", Toast.LENGTH_SHORT).show(); ImageView imageView = (ImageView) findViewById(R.id.image1); imageView.setImageResource(imageIDs[position]); } }); } public class ImageAdapter extends BaseAdapter { Context context; int itemBackground; public ImageAdapter(Context c) { context = c; //---setting the style--- TypedArray a = obtainStyledAttributes( R.styleable.Gallery1); itemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } public int getCount() { return imageIDs.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { imageView = new ImageView(context); imageView.setImageResource(imageIDs[position]); imageView.setScaleType( ImageView.ScaleType.FIT_XY); imageView.setLayoutParams( new Gallery.LayoutParams(150, 120)); } else { imageView = (ImageView) convertView; } imageView.setBackgroundResource(itemBackground); return imageView; } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.gallery, menu); return true; } } </code></pre> <p>Here is all of my Logcat:</p> <pre><code>05-10 00:21:29.134: E/Trace(769): error opening trace file: No such file or directory (2) 05-10 00:21:29.174: W/ActivityThread(769): Application net.learn2develop.Gallery is waiting for the debugger on port 8100... 05-10 00:21:29.194: I/System.out(769): Sending WAIT chunk 05-10 00:21:29.374: I/dalvikvm(769): Debugger is active 05-10 00:21:29.414: I/System.out(769): Debugger has connected 05-10 00:21:29.414: I/System.out(769): waiting for debugger to settle... 05-10 00:21:29.624: I/System.out(769): waiting for debugger to settle... 05-10 00:21:29.824: I/System.out(769): waiting for debugger to settle... 05-10 00:21:30.054: I/System.out(769): waiting for debugger to settle... 05-10 00:21:30.264: I/System.out(769): waiting for debugger to settle... 05-10 00:21:30.464: I/System.out(769): waiting for debugger to settle... 05-10 00:21:30.664: I/System.out(769): waiting for debugger to settle... 05-10 00:21:30.944: I/System.out(769): waiting for debugger to settle... 05-10 00:21:31.144: I/System.out(769): debugger has settled (1316) 05-10 00:21:32.484: D/dalvikvm(769): GC_FOR_ALLOC freed 71K, 8% free 2515K/2708K, paused 60ms, total 81ms 05-10 00:21:32.535: I/dalvikvm-heap(769): Grow heap (frag case) to 5.571MB for 3145744-byte allocation 05-10 00:21:32.664: D/dalvikvm(769): GC_FOR_ALLOC freed 2K, 4% free 5585K/5784K, paused 131ms, total 131ms 05-10 00:21:32.774: D/dalvikvm(769): GC_CONCURRENT freed &lt;1K, 4% free 5585K/5784K, paused 9ms+4ms, total 107ms 05-10 00:21:33.524: D/dalvikvm(769): GC_FOR_ALLOC freed &lt;1K, 4% free 5584K/5784K, paused 233ms, total 234ms 05-10 00:21:33.724: I/dalvikvm-heap(769): Grow heap (frag case) to 12.319MB for 7077904-byte allocation 05-10 00:21:33.814: D/dalvikvm(769): GC_CONCURRENT freed 0K, 2% free 12496K/12700K, paused 20ms+16ms, total 87ms 05-10 00:21:34.524: D/libEGL(769): loaded /system/lib/egl/libEGL_emulation.so 05-10 00:21:34.524: D/(769): HostConnection::get() New Host Connection established 0x2a173820, tid 769 05-10 00:21:34.618: D/libEGL(769): loaded /system/lib/egl/libGLESv1_CM_emulation.so 05-10 00:21:34.624: D/libEGL(769): loaded /system/lib/egl/libGLESv2_emulation.so </code></pre> <p>05-10 00:21:34.804: W/EGL_emulation(769): eglSurfaceAttrib not implemented 05-10 00:21:29.489: D/OpenGLRenderer(769): Enabling debug mode 0 05-10 00:21:29.839: D/dalvikvm(769): GC_FOR_ALLOC freed 3073K, 26% free 9763K/13040K, paused 84ms, total 179ms 05-10 00:21:29.849: I/dalvikvm-heap(769): Grow heap (frag case) to 12.650MB for 3145744-byte allocation 05-10 00:21:29.991: D/dalvikvm(769): GC_CONCURRENT freed &lt;1K, 2% free 12834K/13040K, paused 24ms+6ms, total 137ms 05-10 00:21:30.400: D/dalvikvm(769): GC_FOR_ALLOC freed &lt;1K, 2% free 12835K/13040K, paused 39ms, total 39ms 05-10 00:21:30.459: I/dalvikvm-heap(769): Grow heap (frag case) to 19.399MB for 7077904-byte allocation 05-10 00:21:30.619: D/dalvikvm(769): GC_CONCURRENT freed 0K, 2% free 19747K/19956K, paused 73ms+19ms, total 160ms 05-10 00:21:30.869: D/dalvikvm(769): GC_FOR_ALLOC freed 3072K, 17% free 16677K/19956K, paused 40ms, total 41ms 05-10 00:21:30.879: I/dalvikvm-heap(769): Grow heap (frag case) to 19.402MB for 3145744-byte allocation 05-10 00:21:31.041: D/dalvikvm(769): GC_CONCURRENT freed &lt;1K, 2% free 19749K/19956K, paused 74ms+19ms, total 164ms 05-10 00:21:31.449: D/dalvikvm(769): GC_FOR_ALLOC freed &lt;1K, 2% free 19749K/19956K, paused 39ms, total 39ms 05-10 00:21:31.519: I/dalvikvm-heap(769): Grow heap (frag case) to 26.152MB for 7077904-byte allocation 05-10 00:21:31.699: D/dalvikvm(769): GC_CONCURRENT freed 0K, 1% free 26661K/26872K, paused 73ms+20ms, total 178ms 05-10 00:22:17.261: D/dalvikvm(769): GC_FOR_ALLOC freed 3075K, 13% free 23610K/26848K, paused 49ms, total 56ms 05-10 00:22:17.269: I/dalvikvm-heap(769): Grow heap (frag case) to 26.171MB for 3145744-byte allocation 05-10 00:22:17.449: D/dalvikvm(769): GC_CONCURRENT freed &lt;1K, 1% free 26681K/26848K, paused 75ms+19ms, total 183ms 05-10 00:22:17.881: D/dalvikvm(769): GC_FOR_ALLOC freed &lt;1K, 1% free 26681K/26848K, paused 47ms, total 47ms 05-10 00:22:17.881: I/dalvikvm-heap(769): Forcing collection of SoftReferences for 7077904-byte allocation 05-10 00:22:17.949: D/dalvikvm(769): GC_BEFORE_OOM freed 9K, 1% free 26671K/26848K, paused 70ms, total 71ms 05-10 00:22:17.949: E/dalvikvm-heap(769): Out of memory on a 7077904-byte allocation. 05-10 00:22:17.959: I/dalvikvm(769): "main" prio=5 tid=1 RUNNABLE 05-10 00:22:17.959: I/dalvikvm(769): | group="main" sCount=0 dsCount=0 obj=0x40a729a0 self=0x2a00bba8 05-10 00:22:17.959: I/dalvikvm(769): | sysTid=769 nice=0 sched=0/0 cgrp=apps handle=1073849308 05-10 00:22:17.959: I/dalvikvm(769): | state=R schedstat=( 6087547791 3674255993 433 ) utm=429 stm=179 core=0 05-10 00:22:17.959: I/dalvikvm(769): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 05-10 00:22:17.959: I/dalvikvm(769): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502) 05-10 00:22:17.959: I/dalvikvm(769): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355) 05-10 00:22:17.959: I/dalvikvm(769): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785) 05-10 00:22:17.959: I/dalvikvm(769): at android.content.res.Resources.loadDrawable(Resources.java:1965) 05-10 00:22:17.959: I/dalvikvm(769): at android.content.res.Resources.getDrawable(Resources.java:660) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.ImageView.resolveUri(ImageView.java:616) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.ImageView.setImageResource(ImageView.java:349) 05-10 00:22:17.971: I/dalvikvm(769): at net.learn2develop.Gallery.GalleryActivity$ImageAdapter.getView(GalleryActivity.java:93) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.makeAndAddView(Gallery.java:865) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.fillToGalleryRightLtr(Gallery.java:819) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.fillToGalleryRight(Gallery.java:763) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.trackMotionScroll(Gallery.java:393) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.onScroll(Gallery.java:1043) 05-10 00:22:17.971: I/dalvikvm(769): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:572) 05-10 00:22:17.971: I/dalvikvm(769): at android.widget.Gallery.onTouchEvent(Gallery.java:958) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.View.dispatchTouchEvent(View.java:7246) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2168) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1903) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174) 05-10 00:22:17.979: I/dalvikvm(769): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917) 05-10 00:22:17.979: I/dalvikvm(769): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953) 05-10 00:22:17.989: I/dalvikvm(769): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405) 05-10 00:22:17.989: I/dalvikvm(769): at android.app.Activity.dispatchTouchEvent(Activity.java:2410) 05-10 00:22:17.989: I/dalvikvm(769): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.View.dispatchPointerEvent(View.java:7426) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4342) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4382) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.Choreographer.doCallbacks(Choreographer.java:562) 05-10 00:22:17.989: I/dalvikvm(769): at android.view.Choreographer.doFrame(Choreographer.java:530) 05-10 00:22:17.999: I/dalvikvm(769): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) 05-10 00:22:17.999: I/dalvikvm(769): at android.os.Handler.handleCallback(Handler.java:725) 05-10 00:22:17.999: I/dalvikvm(769): at android.os.Handler.dispatchMessage(Handler.java:92) 05-10 00:22:17.999: I/dalvikvm(769): at android.os.Looper.loop(Looper.java:137) 05-10 00:22:17.999: I/dalvikvm(769): at android.app.ActivityThread.main(ActivityThread.java:5041) 05-10 00:22:17.999: I/dalvikvm(769): at java.lang.reflect.Method.invokeNative(Native Method) 05-10 00:22:17.999: I/dalvikvm(769): at java.lang.reflect.Method.invoke(Method.java:511) 05-10 00:22:17.999: I/dalvikvm(769): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 05-10 00:22:17.999: I/dalvikvm(769): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 05-10 00:22:17.999: I/dalvikvm(769): at dalvik.system.NativeStart.main(Native Method) 05-10 00:22:18.009: D/skia(769): --- allocation failed for scaled bitmap 05-10 00:22:19.089: E/InputEventReceiver(769): Exception dispatching input event.</p> <p>Could someone could enlighten me? Any help is much appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload