Remove item in arrayList , java.lang.UnsupportedOperationException - android

I want remove item in array list select location
My code is
List<String> historylist = Arrays.asList(history);
if (historylist.size()>=3){
System.out.print("*************************************************");
Log.i(MyContants.StoredHistory_TAG,"StoredHistory size========="+ String.valueOf(historylist.size()));
String removePosition=historylist.get(2);
historylist.remove(removePosition);
}
but i got a Exception UnsupportedOperationException
error
12-20 09:16:27.680: I/StoredHistory Class(5715): StoredHistory size=========3
12-20 09:16:27.680: D/AndroidRuntime(5715): Shutting down VM
12-20 09:16:27.684: W/dalvikvm(5715): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
12-20 09:16:27.688: E/AndroidRuntime(5715): FATAL EXCEPTION: main
12-20 09:16:27.688: E/AndroidRuntime(5715): java.lang.RuntimeException: Unable to start activity ComponentInfo{****PACKAGE NAME*****}: java.lang.UnsupportedOperationException
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.os.Looper.loop(Looper.java:123)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 09:16:27.688: E/AndroidRuntime(5715): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-20 09:16:27.688: E/AndroidRuntime(5715): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-20 09:16:27.688: E/AndroidRuntime(5715): at dalvik.system.NativeStart.main(Native Method)
12-20 09:16:27.688: E/AndroidRuntime(5715): Caused by: java.lang.UnsupportedOperationException
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractList.remove(AbstractList.java:645)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:77)
12-20 09:16:27.688: E/AndroidRuntime(5715): at java.util.AbstractCollection.remove(AbstractCollection.java:230)
12-20 09:16:27.688: E/AndroidRuntime(5715): at ******.utills.StoredHistory.storedHistorylist(StoredHistory.java:24)
12-20 09:16:27.688: E/AndroidRuntime(5715): at *******.ScanResult.onCreate(ScanResult.java:53)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-20 09:16:27.688: E/AndroidRuntime(5715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 09:16:27.688: E/AndroidRuntime(5715): ... 11 more
How to cleat this issue .. Advance thanx dude

Change
List<String> historylist = Arrays.asList(history);
to
List<String> historylist = new LinkedList (Arrays.asList(history));
and see this post why this error occur in case of List :
Why do I get an UnsupportedOperationException when trying to remove an element from a List?

You cannot add or remove elements from the list returned by Arrays.asList because the list is backed by the original array. To create a list that you can modify, you can do this:
List<String> historylist = new ArrayList<String>(Arrays.asList(history));

I believe Arrays.asList() creates is fixed-length, and so does not support removing.
Try using an implementation that supports removing like ArrayList instead.

try this
list.set(position,obj);

Related

IllegalArgumentException from closing service that draws on other apps

I am writing an android app that runs a service in the background that makes use of the OVERLAY_PERMISSION to draw on other apps. It starts with an intent from a button on my main activity. So far, so good.
In my service, in my onDestroy(), I have a if (myView != null) windowManager.removeView(myView);. And when I call stopService from the activity, I get an error, saying:
java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
I am only able to close the service if I comment out that line. However, if I do that, the view remains on the screen even after the service is closed, which is not what I want.
What is the correct way to close the service and detach the view?
Full Trace:
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: FATAL EXCEPTION: main
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Process: com.supernovaapps.cameralevel, PID: 21233
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3059)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:424)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:350)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:111)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.supernovaapps.cameralevel.LevelService.onDestroy(LevelService.java:164)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3040)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
Looks like you passed a different view to windowManager than what was added to it before.
Just pass it the right view and it would work.

How to use Mupdf sample project with android SDK

I have a pdf reader proejct with mupdf reader library and i have a Android setup SDK , when i run the sample application it display sd card content list and when i have selected any pdf i will get crashed here is the log .
12-20 11:57:57.512: E/AndroidRuntime(12750): FATAL EXCEPTION: main
12-20 11:57:57.512: E/AndroidRuntime(12750): java.lang.UnsatisfiedLinkError: Native method not found: com.artifex.mupdfdemo.MuPDFCore.openFile:(Ljava/lang/String;)J
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.artifex.mupdfdemo.MuPDFCore.openFile(Native Method)
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.artifex.mupdfdemo.MuPDFCore.<init>(MuPDFCore.java:70)
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:216)
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:313)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.Activity.performCreate(Activity.java:5206)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.ActivityThread.access$600(ActivityThread.java:140)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.os.Looper.loop(Looper.java:137)
12-20 11:57:57.512: E/AndroidRuntime(12750): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-20 11:57:57.512: E/AndroidRuntime(12750): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 11:57:57.512: E/AndroidRuntime(12750): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
12-20 11:57:57.512: E/AndroidRuntime(12750): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
12-20 11:57:57.512: E/AndroidRuntime(12750): at dalvik.system.NativeStart.main(Native Method)
please some one tell me how i can run this application
Have a look at this sample project to read PDF with file manger.
apv - APV PDF Viewer
This app using MuPDF to show the PDF file as well using other libraries also to show images and maintain heapsize for that application.
Steps to bulid the library.
Following are the other similar projects to show PDf file which are as follows :
DroidReade
VuDroid

creating an AutoCompleteTextView inside alertDialog

I am trying to add an AutoCompleteTextBox inside an AlertDialog but I have no Idea how to do that. Any help regarding the same would be appreciated. Also In that AutoCompleteTextBox , I want to display the places through google Places API. I have implemented the google Places API for that and it shows the result if I run the url for that but when I enter 2 or more character in the AutoCompleteText Box it shows the following Error:
12-20 15:28:39.020: E/AndroidRuntime(19180): FATAL EXCEPTION: main
12-20 15:28:39.020: E/AndroidRuntime(19180): android.view.InflateException: Binary XML file line #47: Error inflating class fragment
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.AbsListView.obtainView(AbsListView.java:2340)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ListPopupWindow$DropDownListView.obtainView(ListPopupWindow.java:1236)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ListView.measureHeightOfChildren(ListView.java:1250)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1123)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.ListPopupWindow.show(ListPopupWindow.java:532)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1081)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:956)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:938)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.os.Looper.loop(Looper.java:153)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.app.ActivityThread.main(ActivityThread.java:4987)
12-20 15:28:39.020: E/AndroidRuntime(19180): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 15:28:39.020: E/AndroidRuntime(19180): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 15:28:39.020: E/AndroidRuntime(19180): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
12-20 15:28:39.020: E/AndroidRuntime(19180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
12-20 15:28:39.020: E/AndroidRuntime(19180): at dalvik.system.NativeStart.main(Native Method)
12-20 15:28:39.020: E/AndroidRuntime(19180): Caused by: java.lang.IllegalArgumentException: Binary XML file line #47: Duplicate id 0x7f05000e, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:296)
12-20 15:28:39.020: E/AndroidRuntime(19180): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
12-20 15:28:39.020: E/AndroidRuntime(19180): ... 22 more
Below is how I implemented the adapter:
AutoCompleteTextView autoCompView = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
autoCompView.setAdapter(new PlacesAutoCompleteAdapter(this, R.layout.list_item));
and the AutoCompleteTextView in list_item is as follows:
<AutoCompleteTextView
android:id="#+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/BookCabtxt"
android:ems="10"
>
</AutoCompleteTextView>
Note: This is just for trial purpose. In actual , I want to put this AutoCompleteTextView inside an AlertDialog. So Mainly I have 2 Doubts:
1>creating an AutoCompleteTextView inside alertDialog
2>Generating results in that AutoCompleteTextView
If there is anything that is not clear please ask in the comments.thanks in advance and pardon my english and ignorance in andoid development as well.
You need to use the view you created for the Dialog. You should have something that looks like this.
LayoutInflater factory = LayoutInflater.from(MyActivity.this);
final View textEntryView = factory.inflate(R.layout.my_layout, null);
AutoCompleteTextView textViewCountry = (AutoCompleteTextView)textEntryView.findViewById(com.example.FindItNear.R.id.autocomplete_radius);
Here is a link which may help you: AutoCompleteTextView implementation on the AlertDialog

AdMob on Galaxy Nexus - Android App closed itself

I have programmed a simple app for testing some things.
One thing is AdMob.
On most of the Android Phone it works, but on Galaxy S3 or Galaxy Nexus, or on Tablets not. Maybe there is a Problem with the higher resoltuion?
The problem is that the app closes immediately when it starts. I tried to integrate AdMob on XML, but that does not work with the new version really.
Here is my AdMob Code.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
AdView adView = new AdView(this, AdSize.BANNER, "replaced id with this");
//adView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
LinearLayout layout = (LinearLayout)findViewById(R.id.LayoutMain);
layout.addView(adView,0);
adView.loadAd(adRequest);
And here is the LogCat
12-20 18:39:18.056: I/dalvikvm(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-20 18:39:18.066: I/dalvikvm(541): at dalvik.system.NativeStart.main(Native Method)
12-20 18:39:18.086: D/AndroidRuntime(541): Shutting down VM
12-20 18:39:18.096: W/dalvikvm(541): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-20 18:39:18.206: E/AndroidRuntime(541): FATAL EXCEPTION: main
12-20 18:39:18.206: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to start activity ComponentInfo{at.android.dertestloerk/at.android.dertestloerk.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.os.Looper.loop(Looper.java:137)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-20 18:39:18.206: E/AndroidRuntime(541): at dalvik.system.NativeStart.main(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-20 18:39:18.206: E/AndroidRuntime(541): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Activity.setContentView(Activity.java:1835)
12-20 18:39:18.206: E/AndroidRuntime(541): at at.android.dertestloerk.MainActivity.onCreate(MainActivity.java:27)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Activity.performCreate(Activity.java:4465)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 11 more
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: java.lang.reflect.InvocationTargetException
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Constructor.constructNative(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 23 more
12-20 18:39:18.206: E/AndroidRuntime(541): Caused by: java.lang.OutOfMemoryError
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.nativeCreate(Native Method)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.content.res.Resources.loadDrawable(Resources.java:1937)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.View.<init>(View.java:2780)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.View.<init>(View.java:2717)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.view.ViewGroup.<init>(ViewGroup.java:379)
12-20 18:39:18.206: E/AndroidRuntime(541): at android.widget.RelativeLayout.<init>(RelativeLayout.java:174)
12-20 18:39:18.206: E/AndroidRuntime(541): ... 26 more
12-20 18:39:23.096: I/Process(541): Sending signal. PID: 541 SIG: 9
And here is my XML Layout
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/hintergrund"
android:orientation="vertical"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/imageViewLoerg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:src="#drawable/animatedloerg"
tools:ignore="ContentDescription" /> </LinearLayout>
Hope you can help .-)
This has nothing to do with Admob. The error is at:
18:39:18.206: E/AndroidRuntime(541): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout 12-20 18:39:18.206: E/AndroidRuntime(541): at
Ie it is crashing trying to load the XML layout, long before you programmatically ad in the Admob AdView.
Look at your layout, there is a problem there.

My android app suddenly stopped working. Can someone help by deciphering my log cat?

12-20 13:52:15.071: D/AndroidRuntime(278): Shutting down VM
12-20 13:52:15.081: W/dalvikvm(278): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-20 13:52:15.100: E/AndroidRuntime(278): FATAL EXCEPTION: main
12-20 13:52:15.100: E/AndroidRuntime(278): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebonybutler.cexample3/com.ebonybutler.cexample3.Main}: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.os.Looper.loop(Looper.java:123)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 13:52:15.100: E/AndroidRuntime(278): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 13:52:15.100: E/AndroidRuntime(278): at java.lang.reflect.Method.invoke(Method.java:521)
12-20 13:52:15.100: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 13:52:15.100: E/AndroidRuntime(278): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 13:52:15.100: E/AndroidRuntime(278): at dalvik.system.NativeStart.main(Native Method)
12-20 13:52:15.100: E/AndroidRuntime(278): Caused by: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278): at com.ebonybutler.cexample3.Main.onCreate(Main.java:21)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-20 13:52:15.100: E/AndroidRuntime(278): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 13:52:15.100: E/AndroidRuntime(278): ... 11 moreenter code here
These lines here:
12-20 13:52:15.100: E/AndroidRuntime(278): Caused by: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278): at com.ebonybutler.cexample3.Main.onCreate(Main.java:21)
suggest that something being used on line 21 of cexample3.Main.onCreate is null, so the code can't continue to execute.
I suggest placing a breakpoint above that line, then debugging to see what object is supposed to be available there. Then you can drill down to finding why that object isn't available (for example, maybe it wasn't initialized properly, or perhaps it has gone out of scope by that point).
Added:
Based on your comment above
Hi guys, this is what is on line 21:b.setOnClickListener(new OnClickListener() – user1026229
it looks like the object represented with the variable 'b' (b.setOnClickListener...) probably is null. If so, next step is to find out why...
Check that all the ids(for buttons ) you given correctly or not
These are the possible conditions for your problem.
1. you didnt done proper type casting for widgets.
2. some value is null in oncreate method.
so try to check one again main.java oncreate method and check you given all userpermissions properly

Categories

Resources