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.
Related
My android application crashes every time I run/launch it on both the emulator and a real device and returns this error message: Unfortunately "application_name" has stopped!
This is what my logcat looks like:
08-05 22:34:24.452: D/dalvikvm(541): Not late-enabling CheckJNI (already on)
08-05 22:34:25.012: D/AndroidRuntime(541): Shutting down VM
08-05 22:34:25.012: W/dalvikvm(541): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-05 22:34:25.012: E/AndroidRuntime(541): FATAL EXCEPTION: main
08-05 22:34:25.012: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tutorial.sharedpreferences/com.tutorial.sharedpreferences.Main}: java.lang.NullPointerException
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.os.Looper.loop(Looper.java:137)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.reflect.Method.invoke(Method.java:511)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-05 22:34:25.012: E/AndroidRuntime(541): at dalvik.system.NativeStart.main(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): Caused by: java.lang.NullPointerException
08-05 22:34:25.012: E/AndroidRuntime(541): at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:153)
08-05 22:34:25.012: E/AndroidRuntime(541): at com.tutorial.sharedpreferences.Main.<init>(Main.java:13)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.Class.newInstanceImpl(Native Method)
08-05 22:34:25.012: E/AndroidRuntime(541): at java.lang.Class.newInstance(Class.java:1319)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-05 22:34:25.012: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-05 22:34:25.012: E/AndroidRuntime(541): ... 11 more
You are attempting to call getSharedPreferences() from an initializer. You cannot safely call methods you inherit from Activity until after super.onCreate() is called.
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
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
I have add a ImageView and assign a jpg file(a1.jpg), the file is 770Kb. When I run the project, that will Crash and show a lot of error log. I have try another jpg file, the the size is 70KB and run the project, that become no problem. Why? Thanks!
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/Test_string"
android:src="#drawable/a1" />
The error log
02-09 12:47:34.692: D/AndroidRuntime(1023): Shutting down VM
02-09 12:47:34.692: W/dalvikvm(1023): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
02-09 12:47:34.802: E/AndroidRuntime(1023): FATAL EXCEPTION: main
02-09 12:47:34.802: E/AndroidRuntime(1023): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lighter.androidntest4/com.lighter.androidntest4.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.os.Handler.dispatchMessage(Handler.java:99)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.os.Looper.loop(Looper.java:137)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-09 12:47:34.802: E/AndroidRuntime(1023): at java.lang.reflect.Method.invokeNative(Native Method)
02-09 12:47:34.802: E/AndroidRuntime(1023): at java.lang.reflect.Method.invoke(Method.java:511)
02-09 12:47:34.802: E/AndroidRuntime(1023): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-09 12:47:34.802: E/AndroidRuntime(1023): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-09 12:47:34.802: E/AndroidRuntime(1023): at dalvik.system.NativeStart.main(Native Method)
02-09 12:47:34.802: E/AndroidRuntime(1023): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-09 12:47:34.802: E/AndroidRuntime(1023): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-09 12:47:34.802: E/AndroidRuntime(1023): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.Activity.setContentView(Activity.java:1881)
02-09 12:47:34.802: E/AndroidRuntime(1023): at com.lighter.androidntest4.MainActivity.onCreate(MainActivity.java:15)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.Activity.performCreate(Activity.java:5104)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-09 12:47:34.802: E/AndroidRuntime(1023): ... 11 more
02-09 12:47:34.802: E/AndroidRuntime(1023): Caused by: java.lang.reflect.InvocationTargetException
02-09 12:47:34.802: E/AndroidRuntime(1023): at java.lang.reflect.Constructor.constructNative(Native Method)
02-09 12:47:34.802: E/AndroidRuntime(1023): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-09 12:47:34.802: E/AndroidRuntime(1023): ... 24 more
02-09 12:47:34.802: E/AndroidRuntime(1023): Caused by: java.lang.OutOfMemoryError
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.content.res.Resources.loadDrawable(Resources.java:1965)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.widget.ImageView.<init>(ImageView.java:120)
02-09 12:47:34.802: E/AndroidRuntime(1023): at android.widget.ImageView.<init>(ImageView.java:110)
02-09 12:47:34.802: E/AndroidRuntime(1023): ... 27 more
It's probably because you're trying to load too large file. Even your error says so:
Caused by: java.lang.OutOfMemoryError
770KB image is quite large for android application. You should really think about something smaller.
You can also increase heap size for your emulator in AVD, but still in your situation it's better to use smaller image if you can.
Hmmm... it sounds like your drawable may not be setup correctly. Are you sure about the name etc?
The emulator cannot support that large an image, as shown by java.lang.OutOfMemoryError. You should be able to customise the emulator to allow larger memory by going into the AVD manager (I believe it is Max VM application heap size).
I had the same issue and Piotr Chojnacki was right; it was a image size issue. I assume that this is more of an issue for older devices and the emulator.
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);