I have two inner fragments in a activity.
Activity is called: MainFragmentActivity (extends FragmentACtivity)
Inside is this:
public static class FeaturedFrag extends ListFragment {
public static class TopFrag extends ListFragment {
How would I identify here?
<fragment
android:id="#+id/featured_frag"
android:layout_width="400dp"
android:layout_height="match_parent"
class="com.---.---.MainFragmentActvity$FeaturedFrag" />
<fragment
android:id="#+id/top_items_frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.---.---.MainFragmentActvity$TopItemFrag" />
Changed the XML to the recommendation, LogCat below.
12-05 00:27:35.639: E/AndroidRuntime(1243): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.---.---.MainFragmentActvit$MasterFrag: make sure class name exists, is public, and has an empty constructor that is public
I do have a class with that name, an empty constructor and it is public.
Full LogCat:
12-05 00:37:38.090: E/AndroidRuntime(1384): FATAL EXCEPTION: main
12-05 00:37:38.090: E/AndroidRuntime(1384): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.---.---/com.---.---.master.MainFragmentActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.os.Looper.loop(Looper.java:137)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-05 00:37:38.090: E/AndroidRuntime(1384): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 00:37:38.090: E/AndroidRuntime(1384): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 00:37:38.090: E/AndroidRuntime(1384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-05 00:37:38.090: E/AndroidRuntime(1384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-05 00:37:38.090: E/AndroidRuntime(1384): at dalvik.system.NativeStart.main(Native Method)
12-05 00:37:38.090: E/AndroidRuntime(1384): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-05 00:37:38.090: E/AndroidRuntime(1384): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.Activity.setContentView(Activity.java:1867)
12-05 00:37:38.090: E/AndroidRuntime(1384): at com.---.---.master.MainFragmentActivity.onCreate(MainFragmentActivity.java:85)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.Activity.performCreate(Activity.java:5008)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-05 00:37:38.090: E/AndroidRuntime(1384): ... 11 more
12-05 00:37:38.090: E/AndroidRuntime(1384): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.---.---.MainFragmentActivity$MasterFrag: make sure class name exists, is public, and has an empty constructor that is public
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.support.v4.app.Fragment.instantiate(Fragment.java:395)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.support.v4.app.Fragment.instantiate(Fragment.java:363)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:264)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
12-05 00:37:38.090: E/AndroidRuntime(1384): ... 21 more
12-05 00:37:38.090: E/AndroidRuntime(1384): Caused by: java.lang.ClassNotFoundException: com.kickinglettce.rate_this.MainFragmentActivity$MasterFrag
12-05 00:37:38.090: E/AndroidRuntime(1384): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-05 00:37:38.090: E/AndroidRuntime(1384): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-05 00:37:38.090: E/AndroidRuntime(1384): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-05 00:37:38.090: E/AndroidRuntime(1384): at android.support.v4.app.Fragment.instantiate(Fragment.java:385)
12-05 00:37:38.090: E/AndroidRuntime(1384): ... 24 more
Sample code from one of the inner fragments:
public static class MasterFrag extends ListFragment {
// fields
public MasterFrag() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.mastercat, container, false);
}
Proofread all your code. Make sure all class names are the same, are in the same packages, etc. Otherwise Android does not know where anything is.
As for your your original question, the format is class = "package.Activity$Fragment"
Related
I want to sync my local app database with my remote server database using android sync adapter. I followed all steps mentioned in developer website and I double checked every thing. but I get null pointer when lines below executed in my MainActivity oncreate:
mAccount = CreateSyncAccount(this);
ContentResolver.setSyncAutomatically(mAccount, AUTHORITY, true);
here is my stacktrace:
12-05 15:05:40.099: E/AndroidRuntime(13641): FATAL EXCEPTION: main
12-05 15:05:40.099: E/AndroidRuntime(13641): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobinMahsaz.dortan/com.mobinMahsaz.dortan.MainActivity2}: java.lang.NullPointerException
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.os.Looper.loop(Looper.java:130)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread.main(ActivityThread.java:3687)
12-05 15:05:40.099: E/AndroidRuntime(13641): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 15:05:40.099: E/AndroidRuntime(13641): at java.lang.reflect.Method.invoke(Method.java:507)
12-05 15:05:40.099: E/AndroidRuntime(13641): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-05 15:05:40.099: E/AndroidRuntime(13641): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-05 15:05:40.099: E/AndroidRuntime(13641): at dalvik.system.NativeStart.main(Native Method)
12-05 15:05:40.099: E/AndroidRuntime(13641): Caused by: java.lang.NullPointerException
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.os.Parcel.readException(Parcel.java:1328)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.os.Parcel.readException(Parcel.java:1276)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.content.IContentService$Stub$Proxy.setSyncAutomatically(IContentService.java:568)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.content.ContentResolver.setSyncAutomatically(ContentResolver.java:1047)
12-05 15:05:40.099: E/AndroidRuntime(13641): at com.mobinMahsaz.dortan.MainActivity2.onCreate(MainActivity2.java:283)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-05 15:05:40.099: E/AndroidRuntime(13641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
12-05 15:05:40.099: E/AndroidRuntime(13641): ... 11 more
I can't find any documentation that states what is the reason of this exception.
EDIT:
After reading ContentResolver documentation I find out null pointer cause by getcontentService().
It could be different for you, but for me this was caused because I had a null mAccount object. I had incorrectly assumed that if AccountManager.addAccountExplicitly returned false then there had been a fatal error, so was returning a null Account from my CreateSyncAccount function in that situation.
I have been trying to implement a sample application in order to study the working of Google maps API. I have been struck with the configuration itself. I can't seem to run the application.
Here's my code at Github :-
https://github.com/siva54/SampleMapApplication
And here's my logcat :-
02-11 15:09:07.492: I/Process(10080): Sending signal. PID: 10080 SIG: 9
02-11 15:09:17.012: E/dalvikvm(10364): Could not find class 'com.google.android.gms.maps.model.MarkerOptions', referenced from method com.myapp.gasapplication.MainActivity.setUpMap
02-11 15:09:17.012: W/dalvikvm(10364): VFY: unable to resolve new-instance 455 (Lcom/google/android/gms/maps/model/MarkerOptions;) in Lcom/myapp/gasapplication/MainActivity;
02-11 15:09:17.012: D/dalvikvm(10364): VFY: replacing opcode 0x22 at 0x0004
02-11 15:09:17.012: E/dalvikvm(10364): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.myapp.gasapplication.MainActivity.setUpMapIfNeeded
02-11 15:09:17.012: W/dalvikvm(10364): VFY: unable to resolve check-cast 452 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lcom/myapp/gasapplication/MainActivity;
02-11 15:09:17.012: D/dalvikvm(10364): VFY: replacing opcode 0x1f at 0x000e
02-11 15:09:17.012: D/dalvikvm(10364): DexOpt: unable to opt direct call 0x0cd0 at 0x06 in Lcom/myapp/gasapplication/MainActivity;.setUpMap
02-11 15:09:17.022: D/dalvikvm(10364): DexOpt: unable to opt direct call 0x0ccf at 0x0b in Lcom/myapp/gasapplication/MainActivity;.setUpMap
02-11 15:09:17.072: D/AndroidRuntime(10364): Shutting down VM
02-11 15:09:17.072: W/dalvikvm(10364): threadid=1: thread exiting with uncaught exception (group=0x40e02930)
02-11 15:09:17.082: E/AndroidRuntime(10364): FATAL EXCEPTION: main
02-11 15:09:17.082: E/AndroidRuntime(10364): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.gasapplication/com.myapp.gasapplication.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.os.Looper.loop(Looper.java:137)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-11 15:09:17.082: E/AndroidRuntime(10364): at java.lang.reflect.Method.invokeNative(Native Method)
02-11 15:09:17.082: E/AndroidRuntime(10364): at java.lang.reflect.Method.invoke(Method.java:511)
02-11 15:09:17.082: E/AndroidRuntime(10364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-11 15:09:17.082: E/AndroidRuntime(10364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-11 15:09:17.082: E/AndroidRuntime(10364): at dalvik.system.NativeStart.main(Native Method)
02-11 15:09:17.082: E/AndroidRuntime(10364): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-11 15:09:17.082: E/AndroidRuntime(10364): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.Activity.setContentView(Activity.java:1881)
02-11 15:09:17.082: E/AndroidRuntime(10364): at com.myapp.gasapplication.MainActivity.onCreate(MainActivity.java:25)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.Activity.performCreate(Activity.java:5104)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-11 15:09:17.082: E/AndroidRuntime(10364): ... 11 more
02-11 15:09:17.082: E/AndroidRuntime(10364): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-11 15:09:17.082: E/AndroidRuntime(10364): ... 21 more
02-11 15:09:17.082: E/AndroidRuntime(10364): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: /data/app/com.myapp.gasapplication-1.apk
02-11 15:09:17.082: E/AndroidRuntime(10364): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-11 15:09:17.082: E/AndroidRuntime(10364): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-11 15:09:17.082: E/AndroidRuntime(10364): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-11 15:09:17.082: E/AndroidRuntime(10364): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
02-11 15:09:17.082: E/AndroidRuntime(10364): ... 24 more
02-11 15:10:58.032: E/dalvikvm(10887): Could not find class 'com.google.android.gms.maps.model.MarkerOptions', referenced from method com.myapp.gasapplication.MainActivity.setUpMap
02-11 15:10:58.032: W/dalvikvm(10887): VFY: unable to resolve new-instance 455 (Lcom/google/android/gms/maps/model/MarkerOptions;) in Lcom/myapp/gasapplication/MainActivity;
02-11 15:10:58.032: D/dalvikvm(10887): VFY: replacing opcode 0x22 at 0x0004
02-11 15:10:58.032: E/dalvikvm(10887): Could not find class 'com.google.android.gms.maps.SupportMapFragment', referenced from method com.myapp.gasapplication.MainActivity.setUpMapIfNeeded
02-11 15:10:58.032: W/dalvikvm(10887): VFY: unable to resolve check-cast 452 (Lcom/google/android/gms/maps/SupportMapFragment;) in Lcom/myapp/gasapplication/MainActivity;
02-11 15:10:58.032: D/dalvikvm(10887): VFY: replacing opcode 0x1f at 0x000e
02-11 15:10:58.032: D/dalvikvm(10887): DexOpt: unable to opt direct call 0x0cd0 at 0x06 in Lcom/myapp/gasapplication/MainActivity;.setUpMap
02-11 15:10:58.032: D/dalvikvm(10887): DexOpt: unable to opt direct call 0x0ccf at 0x0b in Lcom/myapp/gasapplication/MainActivity;.setUpMap
02-11 15:10:58.092: D/AndroidRuntime(10887): Shutting down VM
02-11 15:10:58.092: W/dalvikvm(10887): threadid=1: thread exiting with uncaught exception (group=0x40e02930)
02-11 15:10:58.092: E/AndroidRuntime(10887): FATAL EXCEPTION: main
02-11 15:10:58.092: E/AndroidRuntime(10887): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.gasapplication/com.myapp.gasapplication.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.os.Looper.loop(Looper.java:137)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-11 15:10:58.092: E/AndroidRuntime(10887): at java.lang.reflect.Method.invokeNative(Native Method)
02-11 15:10:58.092: E/AndroidRuntime(10887): at java.lang.reflect.Method.invoke(Method.java:511)
02-11 15:10:58.092: E/AndroidRuntime(10887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-11 15:10:58.092: E/AndroidRuntime(10887): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-11 15:10:58.092: E/AndroidRuntime(10887): at dalvik.system.NativeStart.main(Native Method)
02-11 15:10:58.092: E/AndroidRuntime(10887): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-11 15:10:58.092: E/AndroidRuntime(10887): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.Activity.setContentView(Activity.java:1881)
02-11 15:10:58.092: E/AndroidRuntime(10887): at com.myapp.gasapplication.MainActivity.onCreate(MainActivity.java:25)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.Activity.performCreate(Activity.java:5104)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-11 15:10:58.092: E/AndroidRuntime(10887): ... 11 more
02-11 15:10:58.092: E/AndroidRuntime(10887): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-11 15:10:58.092: E/AndroidRuntime(10887): ... 21 more
02-11 15:10:58.092: E/AndroidRuntime(10887): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: /data/app/com.myapp.gasapplication-2.apk
02-11 15:10:58.092: E/AndroidRuntime(10887): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-11 15:10:58.092: E/AndroidRuntime(10887): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-11 15:10:58.092: E/AndroidRuntime(10887): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-11 15:10:58.092: E/AndroidRuntime(10887): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
02-11 15:10:58.092: E/AndroidRuntime(10887): ... 24 more
Would you please help? Thanks in advance.
It looks like it's not finding the Google Maps classes at runtime. Are you running this on a device or an emulator because you can't use Google Maps v2 on an emulator at this time.
If you are running on a device then make sure you have Google Play Services installed. It contains the runtime for Google Maps v2.
Solved my Problem. The issue occurred because even though I i referenced the google play library, The reference is not considered by eclipse and it was shown by a cross mark. I have resolved that with the help of the following stackoverflow post:-
In eclipse, unable to reference an android library project in another android project
I'm using eclipse and making an android app
I'm trying to have a saved setting for a button but when I try to set the button text when the app starts up it fails and i get lots of errors.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
LoadPreferences();
.........
}private void LoadPreferences(){
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
floz = sharedPreferences.getBoolean("floz", false);
Button button = (Button) findViewById(R.id.buttonVolumeType);
button.setText("mls");
}
if I delete the button.setText("mls"); line it works fine
this is the logcat message
12-22 23:35:38.064: E/Trace(1384): error opening trace file: No such file or directory (2) 12-22 23:35:38.663: D/AndroidRuntime(1384): Shutting down VM
12-22 23:35:38.663: W/dalvikvm(1384): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
12-22 23:35:38.684: E/AndroidRuntime(1384): FATAL EXCEPTION: main
12-22 23:35:38.684: E/AndroidRuntime(1384): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.cheapchug/com.example.cheapchug.MainActivity}: java.lang.NullPointerException
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.os.Handler.dispatchMessage(Handler.java:99)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.os.Looper.loop(Looper.java:137)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-22 23:35:38.684: E/AndroidRuntime(1384): at java.lang.reflect.Method.invokeNative(Native Method)
12-22 23:35:38.684: E/AndroidRuntime(1384): at java.lang.reflect.Method.invoke(Method.java:511)
12-22 23:35:38.684: E/AndroidRuntime(1384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-22 23:35:38.684: E/AndroidRuntime(1384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-22 23:35:38.684: E/AndroidRuntime(1384): at dalvik.system.NativeStart.main(Native Method)
12-22 23:35:38.684: E/AndroidRuntime(1384): Caused by: java.lang.NullPointerException
12-22 23:35:38.684: E/AndroidRuntime(1384): at com.example.cheapchug.MainActivity.LoadPreferences(MainActivity.java:260)
12-22 23:35:38.684: E/AndroidRuntime(1384): at com.example.cheapchug.MainActivity.onCreate(MainActivity.java:70)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.Activity.performCreate(Activity.java:5008)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-22 23:35:38.684: E/AndroidRuntime(1384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-22 23:35:38.684: E/AndroidRuntime(1384): ... 11 more
in the onCreate Method the line setContentView(R.layout.main); loads only main.xml so the button hasn't been loaded yet and the button text can't be changed.
but by the time onCreateOptionsMenu(Menu menu) gets run the tab.xml files for the swiping view are loaded.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am developing an app for all android devices. It is working good on all device and I tested it on Samsung Galaxy S1, Galaxy Nexus, Motorola Xoom, HTC One and also on Amazon Kindle Fire.
It runs perfectly on all devices but when i tried using it on Nexus 7, it crashes and in log it says Out of Memory Error. I tried using System.gc(); in Activity#onPause() method but in vain. There are alternative drawables and layouts exist in app.
Please help me to resolve this issue. This issue is only specific to Nexus 7.
Below is stacktrace:
12-05 16:42:45.625: E/AndroidRuntime(8759): FATAL EXCEPTION: main
12-05 16:42:45.625: E/AndroidRuntime(8759): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.app/com.android.app.activity.MyListActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.os.Looper.loop(Looper.java:137)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-05 16:42:45.625: E/AndroidRuntime(8759): at dalvik.system.NativeStart.main(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Activity.setContentView(Activity.java:1881)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.app.activity.MyListActivity.onCreate(MyListActivity.java:39)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Activity.performCreate(Activity.java:5104)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 11 more
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: java.lang.reflect.InvocationTargetException
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Constructor.constructNative(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 23 more
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: java.lang.OutOfMemoryError
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.content.res.Resources.loadDrawable(Resources.java:1965)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.View.<init>(View.java:3328)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.ViewGroup.<init>(ViewGroup.java:431)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 26 more
Thanks in advance.
Ya i had faced this issue too but not found a valid solution but you can try using android:largeHeap="true" in manifest at application level
I have an Android application in Eclipse Indigo with ADT version 15. Upgrading ADT to the version 21 the program crashes and is impossible to execute over both the emulator and the mobile device.
LogCat shows this error message:
12-05 10:07:35.960: E/AndroidRuntime(31462): FATAL EXCEPTION: main
12-05 10:07:35.960: E/AndroidRuntime(31462): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.hello/test.StartActivityZZ}: java.lang.ClassNotFoundException: test.start.StartActivityZZ
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread.access$600(ActivityThread.java:140)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.os.Looper.loop(Looper.java:137)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-05 10:07:35.960: E/AndroidRuntime(31462): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 10:07:35.960: E/AndroidRuntime(31462): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 10:07:35.960: E/AndroidRuntime(31462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
12-05 10:07:35.960: E/AndroidRuntime(31462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
12-05 10:07:35.960: E/AndroidRuntime(31462): at dalvik.system.NativeStart.main(Native Method)
12-05 10:07:35.960: E/AndroidRuntime(31462): Caused by: java.lang.ClassNotFoundException: test.start.StartActivityZZ
12-05 10:07:35.960: E/AndroidRuntime(31462): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-05 10:07:35.960: E/AndroidRuntime(31462): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-05 10:07:35.960: E/AndroidRuntime(31462): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
12-05 10:07:35.960: E/AndroidRuntime(31462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
12-05 10:07:35.960: E/AndroidRuntime(31462): ... 11 more
The Android project uses maven but creating a new one without maven the problem persists and shows the same message.
Any suggestions to fix this problem?
Thanks
At some point (probably after ver 15), the libraries you use must be placed in the "libs" folder. Try placing a copy of your libraries there and retry