I have created one java class and one layout with image button. When I set content view it throws runtime exception.
Error:
02-02 17:46:39.558: E/AndroidRuntime(954): FATAL EXCEPTION: main
02-02 17:46:39.558: E/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oceans/com.oceans.LettersScreenActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:137)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-02 17:46:39.558: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 17:46:39.558: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-02 17:46:39.558: E/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
02-02 17:46:39.558: E/AndroidRuntime(954): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-02 17:46:39.558: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-02 17:46:39.558: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
Xml Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/letters_bg" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="49dp"
android:src="#drawable/leftsignpost" />
</RelativeLayout>
Java Class Code :
public class LettersScreenActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.letters_screen); // error is here
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
So what is the problem?
Why it is throwing runtime exception ??
I've tried this code ...Its really working fine ... please check your Image and manifest file
There are no any obvious problems in the code provided, should run? At least does for me (the drawables are mine, of course).
Check if you have the referenced resources letters_bg and leftsignpost in place. These must be under res/drawable . Clean the project. Try to provide the longer stack trace.
Related
I try to run google map from this page https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
This is my
.java page
package com.findyourtaxihere.taxi;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
This is Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.findyourtaxihere.taxi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<permission
android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.my api"
android:value="my api"/>
</application>
</manifest>
my activity main
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
when run my app , it shows error like this stops unfortunately , and i'm new for android please help me !
log
02-02 19:03:54.871: I/Process(284): Sending signal. PID: 284 SIG: 9
02-02 19:04:00.491: D/AndroidRuntime(307): Shutting down VM
02-02 19:04:00.491: W/dalvikvm(307): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 19:04:00.511: E/AndroidRuntime(307): FATAL EXCEPTION: main
02-02 19:04:00.511: E/AndroidRuntime(307): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.findyourtaxihere.taxi/com.findyourtaxihere.taxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.os.Looper.loop(Looper.java:123)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 19:04:00.511: E/AndroidRuntime(307): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:04:00.511: E/AndroidRuntime(307): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 19:04:00.511: E/AndroidRuntime(307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 19:04:00.511: E/AndroidRuntime(307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 19:04:00.511: E/AndroidRuntime(307): at dalvik.system.NativeStart.main(Native Method)
02-02 19:04:00.511: E/AndroidRuntime(307): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-02 19:04:00.511: E/AndroidRuntime(307): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.Activity.setContentView(Activity.java:1647)
02-02 19:04:00.511: E/AndroidRuntime(307): at com.findyourtaxihere.taxi.MainActivity.onCreate(MainActivity.java:13)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-02 19:04:00.511: E/AndroidRuntime(307): ... 11 more
02-02 19:04:00.511: E/AndroidRuntime(307): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.findyourtaxihere.taxi-2.apk]
02-02 19:04:00.511: E/AndroidRuntime(307): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 19:04:00.511: E/AndroidRuntime(307): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 19:04:00.511: E/AndroidRuntime(307): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-02 19:04:00.511: E/AndroidRuntime(307): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-02 19:04:00.511: E/AndroidRuntime(307): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-02 19:04:00.511: E/AndroidRuntime(307): ... 19 more
02-02 19:09:36.841: I/dalvikvm(334): Could not find method com.findyourtaxihere.taxi.MainActivity.getFragmentManager, referenced from method com.findyourtaxihere.taxi.MainActivity.onCreate
02-02 19:09:36.841: W/dalvikvm(334): VFY: unable to resolve virtual method 12505: Lcom/findyourtaxihere/taxi/MainActivity;.getFragmentManager ()Landroid/app/FragmentManager;
02-02 19:09:36.841: D/dalvikvm(334): VFY: replacing opcode 0x6e at 0x0009
02-02 19:09:36.852: D/dalvikvm(334): VFY: dead code 0x000c-0019 in Lcom/findyourtaxihere/taxi/MainActivity;.onCreate (Landroid/os/Bundle;)V
02-02 19:09:36.922: D/AndroidRuntime(334): Shutting down VM
02-02 19:09:36.922: W/dalvikvm(334): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 19:09:36.942: E/AndroidRuntime(334): FATAL EXCEPTION: main
02-02 19:09:36.942: E/AndroidRuntime(334): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.findyourtaxihere.taxi/com.findyourtaxihere.taxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.os.Looper.loop(Looper.java:123)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 19:09:36.942: E/AndroidRuntime(334): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:09:36.942: E/AndroidRuntime(334): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 19:09:36.942: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 19:09:36.942: E/AndroidRuntime(334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 19:09:36.942: E/AndroidRuntime(334): at dalvik.system.NativeStart.main(Native Method)
02-02 19:09:36.942: E/AndroidRuntime(334): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-02 19:09:36.942: E/AndroidRuntime(334): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.Activity.setContentView(Activity.java:1647)
02-02 19:09:36.942: E/AndroidRuntime(334): at com.findyourtaxihere.taxi.MainActivity.onCreate(MainActivity.java:18)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-02 19:09:36.942: E/AndroidRuntime(334): ... 11 more
02-02 19:09:36.942: E/AndroidRuntime(334): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.findyourtaxihere.taxi-1.apk]
02-02 19:09:36.942: E/AndroidRuntime(334): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 19:09:36.942: E/AndroidRuntime(334): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 19:09:36.942: E/AndroidRuntime(334): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-02 19:09:36.942: E/AndroidRuntime(334): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-02 19:09:36.942: E/AndroidRuntime(334): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-02 19:09:36.942: E/AndroidRuntime(334): ... 19 more
02-02 19:09:40.241: I/Process(334): Sending signal. PID: 334 SIG: 9
02-02 19:15:23.312: I/dalvikvm(370): Could not find method com.findyourtaxihere.taxi.MainActivity.getFragmentManager, referenced from method com.findyourtaxihere.taxi.MainActivity.onCreate
02-02 19:15:23.312: W/dalvikvm(370): VFY: unable to resolve virtual method 12505: Lcom/findyourtaxihere/taxi/MainActivity;.getFragmentManager ()Landroid/app/FragmentManager;
02-02 19:15:23.312: D/dalvikvm(370): VFY: replacing opcode 0x6e at 0x0009
02-02 19:15:23.322: D/dalvikvm(370): VFY: dead code 0x000c-0019 in Lcom/findyourtaxihere/taxi/MainActivity;.onCreate (Landroid/os/Bundle;)V
02-02 19:15:23.392: D/AndroidRuntime(370): Shutting down VM
02-02 19:15:23.392: W/dalvikvm(370): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 19:15:23.422: E/AndroidRuntime(370): FATAL EXCEPTION: main
02-02 19:15:23.422: E/AndroidRuntime(370): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.findyourtaxihere.taxi/com.findyourtaxihere.taxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.os.Looper.loop(Looper.java:123)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 19:15:23.422: E/AndroidRuntime(370): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:15:23.422: E/AndroidRuntime(370): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 19:15:23.422: E/AndroidRuntime(370): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 19:15:23.422: E/AndroidRuntime(370): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 19:15:23.422: E/AndroidRuntime(370): at dalvik.system.NativeStart.main(Native Method)
02-02 19:15:23.422: E/AndroidRuntime(370): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-02 19:15:23.422: E/AndroidRuntime(370): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.Activity.setContentView(Activity.java:1647)
02-02 19:15:23.422: E/AndroidRuntime(370): at com.findyourtaxihere.taxi.MainActivity.onCreate(MainActivity.java:18)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-02 19:15:23.422: E/AndroidRuntime(370): ... 11 more
02-02 19:15:23.422: E/AndroidRuntime(370): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.findyourtaxihere.taxi-2.apk]
02-02 19:15:23.422: E/AndroidRuntime(370): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 19:15:23.422: E/AndroidRuntime(370): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 19:15:23.422: E/AndroidRuntime(370): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-02 19:15:23.422: E/AndroidRuntime(370): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-02 19:15:23.422: E/AndroidRuntime(370): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-02 19:15:23.422: E/AndroidRuntime(370): ... 19 more
02-02 19:15:26.542: I/Process(370): Sending signal. PID: 370 SIG: 9
02-02 19:18:15.771: I/dalvikvm(397): Could not find method com.findyourtaxihere.taxi.MainActivity.getFragmentManager, referenced from method com.findyourtaxihere.taxi.MainActivity.onCreate
02-02 19:18:15.771: W/dalvikvm(397): VFY: unable to resolve virtual method 12506: Lcom/findyourtaxihere/taxi/MainActivity;.getFragmentManager ()Landroid/app/FragmentManager;
02-02 19:18:15.771: D/dalvikvm(397): VFY: replacing opcode 0x6e at 0x0009
02-02 19:18:15.782: D/dalvikvm(397): VFY: dead code 0x000c-005e in Lcom/findyourtaxihere/taxi/MainActivity;.onCreate (Landroid/os/Bundle;)V
02-02 19:18:15.821: D/AndroidRuntime(397): Shutting down VM
02-02 19:18:15.821: W/dalvikvm(397): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 19:18:15.851: E/AndroidRuntime(397): FATAL EXCEPTION: main
02-02 19:18:15.851: E/AndroidRuntime(397): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.findyourtaxihere.taxi/com.findyourtaxihere.taxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.os.Looper.loop(Looper.java:123)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 19:18:15.851: E/AndroidRuntime(397): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:18:15.851: E/AndroidRuntime(397): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 19:18:15.851: E/AndroidRuntime(397): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 19:18:15.851: E/AndroidRuntime(397): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 19:18:15.851: E/AndroidRuntime(397): at dalvik.system.NativeStart.main(Native Method)
02-02 19:18:15.851: E/AndroidRuntime(397): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-02 19:18:15.851: E/AndroidRuntime(397): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.Activity.setContentView(Activity.java:1647)
02-02 19:18:15.851: E/AndroidRuntime(397): at com.findyourtaxihere.taxi.MainActivity.onCreate(MainActivity.java:20)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-02 19:18:15.851: E/AndroidRuntime(397): ... 11 more
02-02 19:18:15.851: E/AndroidRuntime(397): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.findyourtaxihere.taxi-1.apk]
02-02 19:18:15.851: E/AndroidRuntime(397): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 19:18:15.851: E/AndroidRuntime(397): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 19:18:15.851: E/AndroidRuntime(397): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-02 19:18:15.851: E/AndroidRuntime(397): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-02 19:18:15.851: E/AndroidRuntime(397): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-02 19:18:15.851: E/AndroidRuntime(397): ... 19 more
02-02 19:22:23.441: D/AndroidRuntime(453): Shutting down VM
02-02 19:22:23.441: W/dalvikvm(453): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-02 19:22:23.471: E/AndroidRuntime(453): FATAL EXCEPTION: main
02-02 19:22:23.471: E/AndroidRuntime(453): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.findyourtaxihere.taxi/com.findyourtaxihere.taxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.os.Looper.loop(Looper.java:123)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 19:22:23.471: E/AndroidRuntime(453): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:22:23.471: E/AndroidRuntime(453): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 19:22:23.471: E/AndroidRuntime(453): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 19:22:23.471: E/AndroidRuntime(453): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 19:22:23.471: E/AndroidRuntime(453): at dalvik.system.NativeStart.main(Native Method)
02-02 19:22:23.471: E/AndroidRuntime(453): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-02 19:22:23.471: E/AndroidRuntime(453): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.Activity.setContentView(Activity.java:1647)
02-02 19:22:23.471: E/AndroidRuntime(453): at com.findyourtaxihere.taxi.MainActivity.onCreate(MainActivity.java:16)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-02 19:22:23.471: E/AndroidRuntime(453): ... 11 more
02-02 19:22:23.471: E/AndroidRuntime(453): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.findyourtaxihere.taxi-1.apk]
02-02 19:22:23.471: E/AndroidRuntime(453): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-02 19:22:23.471: E/AndroidRuntime(453): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-02 19:22:23.471: E/AndroidRuntime(453): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-02 19:22:23.471: E/AndroidRuntime(453): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-02 19:22:23.471: E/AndroidRuntime(453): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-02 19:22:23.471: E/AndroidRuntime(453): ... 19 more
02-02 19:27:23.551: I/Process(453): Sending signal. PID: 453 SIG: 9
You need to set your min SDK to 11 so the code can only be run on devices where Activity knows how to inflate fragment tags.
Or just use the v4 support library and change your activity to extend FragmentActivity.
I'm getting the following error trying to start an activity with a Fragment
08-09 13:50:57.070: ERROR/AndroidRuntime(1446): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.zap.imoveis/br.com.zap.imoveis.ui.ResultadoBusca}: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
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:256)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:261)
at br.com.zap.imoveis.ui.ResultadoBusca.onCreate(ResultadoBusca.java:54)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
... 11 more
Caused by: java.lang.ClassCastException: br.com.zap.imoveis.ui.ResultadoBuscaMapa cannot be cast to android.app.Fragment
at android.app.Fragment.instantiate(Fragment.java:577)
at android.app.Fragment.instantiate(Fragment.java:552)
at android.app.Activity.onCreateView(Activity.java:4656)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
... 22 more
Despite of what it says here:
Cannot be cast to android.app.Fragment
I have this error even though my Activity extends from android.support.v4.app.FragmentActivity
Unfortunately, error messages some times are very misleading. I've almost rebuilt my application to find out that during a refactor I have accidentally deleted this line o code
super.onCreate(savedInstanceState);
on the onCreate method of my activity.
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));
}
}
I am working on Map view using android API v2, I am following this tutorial, I have followed what he explained in tutorial, but still I am getting Fatal exception. here is my xml code with log cat.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
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=".MainActivity" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
logcat:
05-08 10:38:22.121: E/AndroidRuntime(954): FATAL EXCEPTION: main
05-08 10:38:22.121: E/AndroidRuntime(954): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.map/com.example.map.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:137)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-08 10:38:22.121: E/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.setContentView(Activity.java:1881)
05-08 10:38:22.121: E/AndroidRuntime(954): at com.example.map.MainActivity.onCreate(MainActivity.java:12)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.performCreate(Activity.java:5104)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 11 more
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:592)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:560)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Activity.onCreateView(Activity.java:4709)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 21 more
05-08 10:38:22.121: E/AndroidRuntime(954): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: /data/app/com.example.map-2.apk
05-08 10:38:22.121: E/AndroidRuntime(954): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-08 10:38:22.121: E/AndroidRuntime(954): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-08 10:38:22.121: E/AndroidRuntime(954): at android.app.Fragment.instantiate(Fragment.java:582)
05-08 10:38:22.121: E/AndroidRuntime(954): ... 24 more
And my manifest is looks like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.map.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.map.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDSW0CfwDN0LyrF8PBeihEjrAkj25TDhUQ" />
</application>
</manifest>
You are trying to import existing project into library. You should be importing the library using following method.
Right click package explorer. Import -> Expand Android -> Existing
Android Code Into Workspace.
Select the google-play-services library. And check the copy to
workspace checkbox.
Once this is done. Reference the library project
Right click on the project. Select Android in the left pane. In the right pane bottom you would see a frame with label Library. Click on add and add the imported library.
To add support library to your project:
Right click on the project Androids Tools -> Add Support library.
If you decide to use support libraries you will have to replace the code
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
with
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
also in your java file you will have to use SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
Make sure that you are using Google APIs in the project build target. Go to project Properties > Android to check this.
Are you using the correct API (GOOGLE API) in Eclipse? Make sure to use the GOOGLE APIs if you want to use google maps in android!
You are probably having an import problem. Just check in right click on project -> properties -> Java build path you have imported the libs. See this link for clarity
This error is usually derived from incorrect referencing of google-play-services library.
To do it correctly please follow the first 3 steps of this blog post guide I wrote on integrating Google Maps API V2 in your application:
Google Maps API V2
""Caused by: java.lang.ClassNotFoundException: Didn't find class"com.google.android.gms.maps.MapFragment" on path: /data/app/com.example.map-2.apk""
Have you checked this?
I think you should Add this (com.google.android.gms.maps.MapFragment)ACTIVITY in your AndroidManifest.XML.
Give a try to the three "caused by..." errors in the LogCat.
I have been trying to get the OpenTok Android hello world working but it keeps crashing on launch. After importing the Hello world project, I copied the opentok android sdk into the project and re-built the project in eclipse. The errors all went away but when I run it on my Galaxy Nexus, I get the following error:
02-02 10:01:39.321: E/AndroidRuntime(17238): FATAL EXCEPTION: main
02-02 10:01:39.321: E/AndroidRuntime(17238): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.opentok.helloworld/com.opentok.helloworld.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.opentok.helloworld.MainActivity" on path: /data/app/com.opentok.helloworld-2.apk
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.os.Looper.loop(Looper.java:137)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-02 10:01:39.321: E/AndroidRuntime(17238): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 10:01:39.321: E/AndroidRuntime(17238): at java.lang.reflect.Method.invoke(Method.java:511)
02-02 10:01:39.321: E/AndroidRuntime(17238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-02 10:01:39.321: E/AndroidRuntime(17238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-02 10:01:39.321: E/AndroidRuntime(17238): at dalvik.system.NativeStart.main(Native Method)
02-02 10:01:39.321: E/AndroidRuntime(17238): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.opentok.helloworld.MainActivity" on path: /data/app/com.opentok.helloworld-2.apk
02-02 10:01:39.321: E/AndroidRuntime(17238): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-02 10:01:39.321: E/AndroidRuntime(17238): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-02 10:01:39.321: E/AndroidRuntime(17238): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
02-02 10:01:39.321: E/AndroidRuntime(17238): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
02-02 10:01:39.321: E/AndroidRuntime(17238): ... 11 more
Am I doing something wrong? Should I do something with the Build Path? I am not sure what to do / how to do it.
I also saw this post but could not find out what the solution is.
Any help would be appreciated. Thanks
I encountered this issue before.
what I did is :
delete the "libs" file in the project.
create new folder "libs" in project.
move the jars from "opentok-android-sdk" folder to "libs"
configration build path.
then it is working.
holp this help.
Put the tokbox library jars (there you be 5 or 6 jars as I remeber) into libs folder. That helped me.