I have an app where there is a sliding menu. I have implemented it using the jfeinstein's library. It was working perfectly fine till yesterday but it has stopped working now. I haven't even made any changes to the code. Here is the error report:
08-20 15:02:52.060: E/AndroidRuntime(32366): FATAL EXCEPTION: main
08-20 15:02:52.060: E/AndroidRuntime(32366): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cvapp/com.cvapp.SecondActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.os.Looper.loop(Looper.java:137)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Method.invokeNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Method.invoke(Method.java:511)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-20 15:02:52.060: E/AndroidRuntime(32366): at dalvik.system.NativeStart.main(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper.onCreate(SlidingActivityHelper.java:45)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity.onCreate(SlidingActivity.java:22)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.cvapp.SecondActivity.onCreate(SecondActivity.java:19)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.Activity.performCreate(Activity.java:5206)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 11 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.reflect.InvocationTargetException
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Constructor.constructNative(Native Method)
08-20 15:02:52.060: E/AndroidRuntime(32366): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-20 15:02:52.060: E/AndroidRuntime(32366): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 21 more
08-20 15:02:52.060: E/AndroidRuntime(32366): Caused by: java.lang.NoClassDefFoundError: android.support.v4.view.ViewConfigurationCompat
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.initCustomViewAbove(CustomViewAbove.java:167)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:157)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.<init>(CustomViewAbove.java:152)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:209)
08-20 15:02:52.060: E/AndroidRuntime(32366): at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.<init>(SlidingMenu.java:192)
08-20 15:02:52.060: E/AndroidRuntime(32366): ... 24 more
Here is my code:
main:
package com.cvapp;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class SecondActivity extends SlidingActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
setBehindContentView(R.layout.activity_menu1);
getSlidingMenu().setBehindOffset(100);
SlidingMenu menu = getSlidingMenu();
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
setOnClickListener();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
}
xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#drawable/pic9"
android:clickable="true"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".SecondActivity" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="27dp"
android:text="Hello"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold" />
</RelativeLayout>
And, if it helps, I have followed this tutorial to set up the Sliding Menu.
FYI, you'd better add support package v4 from library project, instead of copy it to local libs. And remember to add library to your sliding menu application.
Finally I got it.. u just have to right click on your project > Android Tools > Add Support Library, so the prblem was the missing support package v4..
I have got the same issue and I have resolved finally Opening the gradle.properties and added following:
android.enableAapt2=false
Related
I am using following code for SQLConnection in android:
public void queryResultSet(String CommandSQL) throws ClassNotFoundException, java.sql.SQLException
{
ResultSet rs;
Connection conn = null;
Toast msg1 = Toast.makeText(getBaseContext(),
"Name = " + CommandSQL, Toast.LENGTH_LONG);
msg1.show();
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String username="14Graficali\\Administrator";
String ConnUrl="jdbc:jtds:sqlserver://14GRAFICALI\\MSSQLSERVER2008;DatabaseName=DVDKiosk;user=14Graficali\\Administrator;Instance=SQLExpress";
conn = DriverManager.getConnection(ConnUrl);
Statement st=conn.createStatement();
rs=st.executeQuery(CommandSQL);
while(rs.next())
{
Toast msg2 = Toast.makeText(getBaseContext(),
"Name = " + rs.getString("UserName"), Toast.LENGTH_LONG);
msg2.show();
}
}
I have included net.sourceforge.jtds.jdbc.Driver as we can see below :
Stack Trace:
08-20 10:57:42.087: W/System.err(400): java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
08-20 10:57:42.087: W/System.err(400): at java.lang.Class.classForName(Native Method)
08-20 10:57:42.087: W/System.err(400): at java.lang.Class.forName(Class.java:234)
08-20 10:57:42.087: W/System.err(400): at java.lang.Class.forName(Class.java:181)
08-20 10:57:42.087: W/System.err(400): at com.example.registrationapp.Login.queryResultSet(Login.java:93)
08-20 10:57:42.087: W/System.err(400): at com.example.registrationapp.Login$1.onClick(Login.java:126)
08-20 10:57:42.087: W/System.err(400): at android.view.View.performClick(View.java:2485)
08-20 10:57:42.087: W/System.err(400): at android.view.View$PerformClick.run(View.java:9080)
08-20 10:57:42.087: W/System.err(400): at android.os.Handler.handleCallback(Handler.java:587)
08-20 10:57:42.087: W/System.err(400): at android.os.Handler.dispatchMessage(Handler.java:92)
08-20 10:57:42.098: W/System.err(400): at android.os.Looper.loop(Looper.java:123)
08-20 10:57:42.098: W/System.err(400): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-20 10:57:42.098: W/System.err(400): at java.lang.reflect.Method.invokeNative(Native Method)
08-20 10:57:42.098: W/System.err(400): at java.lang.reflect.Method.invoke(Method.java:507)
08-20 10:57:42.098: W/System.err(400): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-20 10:57:42.098: W/System.err(400): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-20 10:57:42.098: W/System.err(400): at dalvik.system.NativeStart.main(Native Method)
08-20 10:57:42.098: W/System.err(400): Caused by: java.lang.NoClassDefFoundError: net.sourceforge.jtds.jdbc.Driver
08-20 10:57:42.107: W/System.err(400): ... 16 more
08-20 10:57:42.107: W/System.err(400): Caused by: java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver in loader dalvik.system.PathClassLoader[/data/app/com.example.registrationapp-1.apk]
08-20 10:57:42.107: W/System.err(400): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-20 10:57:42.107: W/System.err(400): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-20 10:57:42.107: W/System.err(400): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
Please help me.
If you have already added the jtds-1.2.5 driver, good. Otherwise:
Right click on the Project > Properties > Libraries Tab Add the jtds-1.2.5.jar file by clicking on "Add External JARs"
Next, in the Order and Export tab (Right next to Libraries in the Java Build Path window) check the box for jtds-1.2.5.jar (and any other external jars you might have).
This will export the .jar containing the driver with the .apk file.
If you use ProGuard, then your class may be dropped by it because it is used with reflection only. And if you don't, Android can still fail to load class for some reasons. Look at LogCat during your package installation.
right click on the project - properties - java build path - Order and export - tick Android private libraries and all the libraries that u added
I have an app that has 2 main layouts and does use alot of pictures (16). The app works fine but it seems after going between layouts a few times it crashes and I believe it is because it is running out of memory. Im not sure how to fix this besides making the pictures smaller.. any suggestions?
06-14 14:28:10.543584-616/? E/NotificationService: Ignoring notification with icon==0: Notification(pri=0 contentView=null vibrate=null sound=nullnull defaults=0x0 flags=0x62 kind=[null])
06-14 14:28:15.678 19572-19572/?E/dalvikvm-heap: Out of memory on a 2764816-byte allocation.
06-14 14:28:15.698 19572-19572/?E/dalvikvm: Extra info: Footprint=63559KB, Allowed Footprint=65543KB, Trimmed=7916KB
06-14 14:28:15.718 19572-19572/?E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nick.simplequiz.plus/com.nick.simplequiz.plus.saveImage}: android.view.InflateException: Binary XML file line #403: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$600(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5454)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #403: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:363)
at android.app.Activity.setContentView(Activity.java:1912)
at com.nick.simplequiz.plus.saveImage.onCreate(saveImage.java:33)
at android.app.Activity.performCreate(Activity.java:5066)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
... 26 more
Caused by: java.lang.OutOfMemoryError: (Heap Size=65543KB, Allocated=57586KB)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:626)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:473)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
at android.content.res.Resources.loadDrawable(Resources.java:1959)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:120)
at android.widget.ImageView.<init>(ImageView.java:110)
... 29 more
06-14 14:28:15.728 584-595/?E/EmbeddedLogger: App crashed! Process: com.nick.simplequiz.plus
06-14 14:28:15.728 584-595/?E/EmbeddedLogger: App crashed! Package: com.nick.simplequiz.plus v6 (1.0)
06-14 14:28:15.728 584-595/?E/EmbeddedLogger: Application Label: Name the plane plus!
I ran into a similar issue before. I believe the
issue is due to recreating the bitmap every time
you start the activity. Here's a snippet of what
i did to get rid of the issue.
Bitmap d;
private void setImage(String path){
if(d != null){
d.recycle();
}
d = BitmapFactory.decodeFile(path);
if(d != null){
profilePicture.setImageDrawable(new BitmapDrawable(d));
}
}
Sometimes by starting my activity which only contains a WebView I got this strange log from LogCat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.cb.pwapp/de.cb.pwapp.Artikel}:
android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
at android.app.Activity.setContentView(Activity.java:1924)
at de.cb.pwapp.Artikel.onCreate(Artikel.java:26)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
... 24 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
at android.content.res.Resources.loadDrawable(Resources.java:1963)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:3449)
at android.view.ViewGroup.<init>(ViewGroup.java:432)
at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:52)
at android.webkit.WebView.<init>(WebView.java:505)
at android.webkit.WebView.<init>(WebView.java:482)
at android.webkit.WebView.<init>(WebView.java:468)
at android.webkit.WebView.<init>(WebView.java:457)
Is it correct that my WebView runs out of memory ?
I load the WebView with a long string, representing an article, from my SQLite DB.
Any ideas how to fix this problem ?
High Res Pics as a Background was the Problem
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 try to use OSMdroid in one of my applictions, but i got this:
running on hardware device Android 4.0.3 (CM9)
log from logcat:
06-25 16:56:07.389: E/AndroidRuntime(17760): java.lang.RuntimeException: Unable to start activity ComponentInfo{app.OSMMapViewActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.access$600(ActivityThread.java:132)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.os.Handler.dispatchMessage(Handler.java:99)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.os.Looper.loop(Looper.java:137)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.main(ActivityThread.java:4575)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.reflect.Method.invokeNative(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.reflect.Method.invoke(Method.java:511)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-25 16:56:07.389: E/AndroidRuntime(17760): at dalvik.system.NativeStart.main(Native Method)
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-25 16:56:07.389: E/AndroidRuntime(17760): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Activity.setContentView(Activity.java:1835)
06-25 16:56:07.389: E/AndroidRuntime(17760): at app.OSMMapViewActivity.onCreate(OSMMapViewActivity.java:16)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Activity.performCreate(Activity.java:4465)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
06-25 16:56:07.389: E/AndroidRuntime(17760): ... 11 more
06-25 16:56:07.389: E/AndroidRuntime(17760): Caused by: java.lang.ClassNotFoundException: org.osmdroid.views.MapView
06-25 16:56:07.389: E/AndroidRuntime(17760): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-25 16:56:07.389: E/AndroidRuntime(17760): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-25 16:56:07.389: E/AndroidRuntime(17760): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-25 16:56:07.389: E/AndroidRuntime(17760): ... 21 more
i hope this will help you more.
mapscreen.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<org.osmdroid.views.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
this is my activity:
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
public class OSMMapViewActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapscreen);
MapView mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(TileSourceFactory.MAPNIK);
mMapView.setBuiltInZoomControls(true);
MapController mMapController = mMapView.getController();
mMapController.setZoom(13);
GeoPoint gPt = new GeoPoint(51500000, -150000);
//Centre map near to Hyde Park Corner, London
mMapController.setCenter(gPt);
}
}
i'm using OSMDroid 3.0.8 and slf4j-1.5.8 and eclipse.
EDIT:
I commented out the setContentView() and the other code. I think the problem is something eith the layout files...
EDIT1:
The Problem is solved... :)
copy osmdroid and the other jars from libs/osmdroid
to libs/ ^_^
Thanks for help anyway!!!!
Thx for helping
Have you added the proper permissions in your Android Manifest file?
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Missing either of these, although ACCESS_FINE_LOCATION could be replaced by ACCESS_COARSE_LOCATION, will usually cause any type of MapView to fail.
The problem is that eclipse need a restart, to load external libraries correct.
Thanks for all your help!!!
I had the same problem.
I solved it by:
cd into the libs folder of your project.
ls .
Notice, there is only one of the required libs. The osmdroid-android-4.0.jar is absent.
Copy it from where you downloaded and saved it from, into this folder.
Run the application now. I should work.
Note: I had already added it to the project path by selecting the project->properties->Java Built path->Libraries.
The required libs are:
slf4j-android-1.5.8.jar
osmdroid-android-4.0.jar