I was following GCM Tutorial and I took utmost care in making no mistake and implementing same code in my project. But when I run the project I am getting ClassCast exception. I thought I would have missed something so I downloaded the source from that post and copied each and every line carefully in my project but still I am getting same exception. Please help solve the error.
12-10 23:41:25.812: E/AndroidRuntime(9549): FATAL EXCEPTION: main
12-10 23:41:25.812: E/AndroidRuntime(9549): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exaple.oldgcm/com.exaple.oldgcm.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.exaple.oldgcm.Controller
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.access$600(ActivityThread.java:128)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.os.Looper.loop(Looper.java:137)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.main(ActivityThread.java:4517)
12-10 23:41:25.812: E/AndroidRuntime(9549): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 23:41:25.812: E/AndroidRuntime(9549): at java.lang.reflect.Method.invoke(Method.java:511)
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
12-10 23:41:25.812: E/AndroidRuntime(9549): at dalvik.system.NativeStart.main(Native Method)
12-10 23:41:25.812: E/AndroidRuntime(9549): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.exaple.oldgcm.Controller
12-10 23:41:25.812: E/AndroidRuntime(9549): at com.exaple.oldgcm.MainActivity.onCreate(MainActivity.java:33)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.Activity.performCreate(Activity.java:4470)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
12-10 23:41:25.812: E/AndroidRuntime(9549): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
12-10 23:41:25.812: E/AndroidRuntime(9549): ... 11 more
I believe the problem is that you haven't set an Application name in your manifest.
Refer to this solution:
android classcastexception at android.app.Application
Related
When i run my java code in the emulator or the real device, i every once in a while get this error. However, the app goes on and installs well. Since the error below appears in red text in my eclipse log, i have been forced to ask.. Is it an error that can cause significant problems when i release the app eventually or its something i should ignore? My guess is that i can use a try catch statement to capture the NullPointerException but i have no clue at what point in my MainActivity this error is generated.
12-10 20:15:44.268: E/AndroidRuntime(1126): FATAL EXCEPTION: main
12-10 20:15:44.268: E/AndroidRuntime(1126): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.os.Looper.loop(Looper.java:137)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-10 20:15:44.268: E/AndroidRuntime(1126): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 20:15:44.268: E/AndroidRuntime(1126): at java.lang.reflect.Method.invoke(Method.java:511)
12-10 20:15:44.268: E/AndroidRuntime(1126): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-10 20:15:44.268: E/AndroidRuntime(1126): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-10 20:15:44.268: E/AndroidRuntime(1126): at dalvik.system.NativeStart.main(Native Method)
12-10 20:15:44.268: E/AndroidRuntime(1126): Caused by: java.lang.NullPointerException
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
12-10 20:15:44.268: E/AndroidRuntime(1126): at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
12-10 20:15:44.268: E/AndroidRuntime(1126): ... 11 more
This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
GoogleAPI key V2 RuntimeException [closed]
(1 answer)
Closed 8 years ago.
Im Creating an app step by step using this tutorial : google map api v2
But I'm getting Error ! I already tried and read many answer to resolve the error! But I can't resolve it
Logcat :
12-10 10:30:02.975: E/AndroidRuntime(2249): FATAL EXCEPTION: main
12-10 10:30:02.975: E/AndroidRuntime(2249): Process: com.example.finalymapapi, PID: 2249
12-10 10:30:02.975: E/AndroidRuntime(2249): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.finalymapapi/com.example.finalymapapi.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.os.Handler.dispatchMessage(Handler.java:102)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.os.Looper.loop(Looper.java:136)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.main(ActivityThread.java:5017)
12-10 10:30:02.975: E/AndroidRuntime(2249): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 10:30:02.975: E/AndroidRuntime(2249): at java.lang.reflect.Method.invoke(Method.java:515)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-10 10:30:02.975: E/AndroidRuntime(2249): at dalvik.system.NativeStart.main(Native Method)
12-10 10:30:02.975: E/AndroidRuntime(2249): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Activity.setContentView(Activity.java:1929)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.example.finalymapapi.MainActivity.onCreate(MainActivity.java:14)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Activity.performCreate(Activity.java:5231)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
12-10 10:30:02.975: E/AndroidRuntime(2249): ... 11 more
12-10 10:30:02.975: E/AndroidRuntime(2249): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.internal.u.B(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.internal.u.A(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment$b.ip(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-10 10:30:02.975: E/AndroidRuntime(2249): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-10 10:30:02.975: E/AndroidRuntime(2249): ... 20 more
Im get SHA1 from eclipse->Window->Preferences->android->Build
and my Manifist file :
<permission
android:name="your_package_name.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="your_package_name.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"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.finalymapapi.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="AIzaSyAHkTtRSWMcC-mUz9jH9CBlrxoeV2Qon7c"/>
</application>
</manifest>
and my activity file :
My javafile :
add <meta-data> tag in <application> tag in your manifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
if still crashes then check:
Use the mapFragment element as below in the xml
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/lineartab" />
You need to check the project properties:
Does Google API's selected?
Google play service lib project added?
Hope this helps.
As mentioned in the exception add the following line to <application> in you AndroidManifest.xml
<meta-data android:name="com.google.android.gms.version"android:value="#integer/google_play_services_version" />
I have used ZBAR library to scan bar code in my Application.
And I got this error log while opening camera on Samsung Galaxy S3 :
java.lang.RuntimeException: startPreview failed
at android.hardware.Camera.startPreview(Native Method)
at com.SGID.MainApp.ScanningFragment.engageCamera(ScanningFragment.java:184)
at com.SGID.MainApp.ScanningFragment.access$10(ScanningFragment.java:154)
at com.SGID.MainApp.ScanningFragment$4.run(ScanningFragment.java:111)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.SGID.MainApp/com.SGID.MainApp.AllTabsActivity}
: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.SGID.MainApp.ParametersFragment.onCreateView(ParametersFragment.java:78)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
at android.app.Activity.performStart(Activity.java:5216)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
... 11 more
EDIT :
Getting error at this line :
CameraPreview mPreview = new CameraPreview(getActivity(), mCamera, previewCb,
autoFocusCB);
Can Anyone help me to resolve this error??
Thanks in advance..
My android is W806 with MIUI system(andrid 2.3.4, could be downloaded at
http://119.147.150.88/gdown_group321/M00/01/BB/d5OWWE-TiE0AAAAABFRc6HZ-Izc1688998/MIUI_W806_updateEX.zip?k=rscjHEFnZBVxNvfDqVP3Iw&t=1355119512&u=712526008-27587528-bjpdc2a8&s=51200&file=MIUI_W806_updateEX.zip
)
I follow this example: http://mirnauman.wordpress.com/2012/01/30/using-google-maps-in-android-development-tutorial-part-1/, I have chosen Google API of 2.3.3 downloaded from SDK manager. But I got the problem Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY.
I try to search solutions in google and stackoverflow, but no one fits me...I have some logcat, and here it is:
12-10 16:38:19.820: W/dalvikvm(5906): Unable to resolve superclass of Lcom/example/googlemapapp/GooglemapsActivity; (463)
12-10 16:38:19.820: W/dalvikvm(5906): Link of class 'Lcom/example/googlemapapp/GooglemapsActivity;' failed
12-10 16:38:19.820: D/AndroidRuntime(5906): Shutting down VM
12-10 16:38:19.820: W/dalvikvm(5906): threadid=1: thread exiting with uncaught exception (group=0x4011b560)
12-10 16:38:19.830: E/AndroidRuntime(5906): FATAL EXCEPTION: main
12-10 16:38:19.830: E/AndroidRuntime(5906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.googlemapapp/com.example.googlemapapp.GooglemapsActivity}: java.lang.ClassNotFoundException: com.example.googlemapapp.GooglemapsActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.googlemapapp-1.apk]
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.os.Looper.loop(Looper.java:130)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.main(ActivityThread.java:3684)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.reflect.Method.invoke(Method.java:507)
12-10 16:38:19.830: E/AndroidRuntime(5906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-10 16:38:19.830: E/AndroidRuntime(5906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-10 16:38:19.830: E/AndroidRuntime(5906): at dalvik.system.NativeStart.main(Native Method)
12-10 16:38:19.830: E/AndroidRuntime(5906): Caused by: java.lang.ClassNotFoundException: com.example.googlemapapp.GooglemapsActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.googlemapapp-1.apk]
12-10 16:38:19.830: E/AndroidRuntime(5906): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-10 16:38:19.830: E/AndroidRuntime(5906): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-10 16:38:19.830: E/AndroidRuntime(5906): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
12-10 16:38:19.830: E/AndroidRuntime(5906): ... 11 more
Looks like you are missing some information in your android project files and/or AndroidManifest.xml ?
Try and look at my earlier answer to a somewhat similar answers:
1. Answer
2. Answer
I am developing an Android app using fragments and would like the user to be able to pick an image for scanning purposes. I have a fragment that allows the user to select their desired source (camera, hand-drawn, or gallery). When the user selects Gallery, then another fragment should display the image. I already know how I am supposed to get the image into an ImageView but keep getting this error with the Fragments:
12-10 17:30:26.405: E/AndroidRuntime(6560): FATAL EXCEPTION: main
12-10 17:30:26.405: E/AndroidRuntime(6560): java.lang.RuntimeException: Unable to resume activity {org.nathanmoos.artificialIntelligence.clockreader/org.nathanmoos.artificialIntelligence.clockreader.ChooseSourceActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2241)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2256)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.os.Looper.loop(Looper.java:130)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.ActivityThread.main(ActivityThread.java:3835)
12-10 17:30:26.405: E/AndroidRuntime(6560): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 17:30:26.405: E/AndroidRuntime(6560): at java.lang.reflect.Method.invoke(Method.java:507)
12-10 17:30:26.405: E/AndroidRuntime(6560): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
12-10 17:30:26.405: E/AndroidRuntime(6560): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
12-10 17:30:26.405: E/AndroidRuntime(6560): at dalvik.system.NativeStart.main(Native Method)
12-10 17:30:26.405: E/AndroidRuntime(6560): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.view.ViewGroup.addView(ViewGroup.java:1871)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.view.ViewGroup.addView(ViewGroup.java:1828)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.view.ViewGroup.addView(ViewGroup.java:1808)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.NoSaveStateFrameLayout.wrap(NoSaveStateFrameLayout.java:40)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:848)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1371)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:499)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.Activity.performStart(Activity.java:3791)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.Activity.performRestart(Activity.java:3821)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.Activity.performResume(Activity.java:3826)
12-10 17:30:26.405: E/AndroidRuntime(6560): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2231)
12-10 17:30:26.405: E/AndroidRuntime(6560): ... 10 more
Basically it looks like there's an issue with my FragmentTransaction usage. Here's my code:
frag = new GalleryFragment();
frag.setImagePath(imagePath);
FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
tx.replace(R.id.fragment_space, frag);
tx.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
and my layout file:
<FrameLayout
android:id="#+id/fragment_space"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="65"/>
Never mind I figured this one out. It's the same solution as:
Android Fragment (with Compatibility Package on 2.3.3) creates "Specified child already has a parent error"
and
Error swapping / adding an XML Fragment
.