Android Google Maps V2 Error inflating fragment - android

I've seen dozens of similar problems but none have seemed to fix my issue. I have an app that uses google maps v2 (previously used v1). I imported google-play-services and android-support-v4, and created an activity that extended SupportFragment (also tried just fragment). I added all permissions and my key to the manifest, and created a fragment in my layout folder which defines the map. However, my app crashes every time I call setContentView on my fragment within my activity. I imported android.support.v4.app.FragmentActivity and android.support.v4.app.Fragment in this activity, but get an error trying to inflate the fragment. The logcat log is listed below. Thanks in advance!
public class ManualCheckInMapActivity extends android.support.v4.app.FragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_fragment);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.safehouse.onguardianmobile/com.safehouse.onguardianmobile.ManualCheckInMapActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:582)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
at android.app.Activity.setContentView(Activity.java:1647)
at com.safehouse.onguardianmobile.ManualCheckInMapActivity.onCreate(ManualCheckInMapActivity.java:40)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
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
at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
... 20 more
Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.safehouse.onguardianmobile-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
... 23 more
UPDATE: I tried cleaning the project, but now get this error. I'm still new at this, no maybe I did not add the libraries properly?
Errors occurred during the build.
Errors running builder 'Android Package Builder' on project 'google-play-services_lib'.
Problems encountered while deleting resources.
Could not delete 'C:\Users\Travis\workspace\google-play-services_lib\bin\google-play-services_lib.jar'.
Problems encountered while deleting files.
Could not delete: C:\workspace\google-play-services_lib\bin\google-play-services_lib.jar.
Problems encountered while deleting resources.
Could not delete 'C:\workspace\google-play-services_lib\bin\google-play-services_lib.jar'.
Problems encountered while deleting files.
Could not delete: C:\Users\Travis\workspace\google-play-services_lib\bin\google-play-services_lib.jar.

Related

Android 2.3.x crashing on com.google.android.gms.location.LocationSettingsResult.startResolutionForResult

I'm in middle of a big issue,
OS VERSION: Android 2.3.x
DEVICE: GT i9100 (samsung galaxy s II)
LOCATION API: com.google.android.gms:play-services-location:9.4.0
PROBLEM: app crash calling
com.google.android.gms.location.LocationSettingsResult.startResolutionForResult
com.google.android.gms.ui E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_height attribute.
FATAL EXCEPTION: main
java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_height attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:543)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3599)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:3678)
at android.widget.LinearLayout$LayoutParams.(LinearLayout.java:1400)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1326)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:47)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:625)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2261)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2316)
at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1478)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2165)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
please refer the following link, i've exactly same issue
https://code.google.com/p/android/issues/detail?id=215183
please help me to fix this
Thanks
Please check solution given in this related SO post by #frieza if it can help.
As suggested, aside from defining layout_height and layout_width attributes shown in the posted codes, you might need to also set parent attribute with parent="android:Theme".
Hope that works for you too.

You must supply a layout_width attribute in some devices

I am experiencing this problem in my app and I can't seem to understand how it happen. It only occurs in Samsung Galaxy Y phone, I tried this code in other devices and it is ok.
java.lang.RuntimeException: Unable to start activity ComponentInfo{jpac.remaster.gtc/jpac.remaster.gtc.GTCSplash}: java.lang.RuntimeException: Binary XML file line #7: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3735)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Binary XML file line #7: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3598)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3678)
at android.widget.RelativeLayout$LayoutParams.<init>(RelativeLayout.java:1169)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:998)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:74)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:625)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at jpac.remaster.gtc.GTCSplash.onCreate(GTCSplash.java:33)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
... 11 more
Can anyone help me with this? btw, here is the xml in question:
<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:background="#color/tuna" >
<ImageView
android:id="#+id/dev_logo"
android:layout_width="#dimen/speech_height"
android:layout_height="#dimen/badge_height"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="#string/empty"
android:scaleType="centerInside"
android:src="#drawable/logo_dark" />
</RelativeLayout>
Also the activity for this xml file is the main entry point of the app.
Thanks in advance.
If you have dimensions (or any other values or resources) specified for particular densities or screen sizes, make sure you also have them defined in the generic directory (i.e. "values", "drawable")

Android Fragment support , java.lang.NoSuchMethodException: Fragment(Context,AttributeSet)

I try to use fragments with AndroidAnnotations and maven.
It worked with Android 4.0+ , but then I tried to make it work with Android 2.3.3 and I had to use the support-v4 maven library:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
My fragment is defined as:
<android.support.v4.app.Fragment android:id="#+id/myFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="com.bla.HeaderFragment_"/>
and My Activity extends FragmentActivity
I get this exception when I run the app:
.....
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.app.Fragment
at android.view.LayoutInflater.createView(LayoutInflater.java:508)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at com.tagonsoft.codecamp.MainActivity_.setContentView(MainActivity_.java:46)
at com.tagonsoft.codecamp.MainActivity_.onCreate(MainActivity_.java:31)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
Caused by: java.lang.NoSuchMethodException: Fragment(Context,AttributeSet)
at java.lang.Class.getMatchingConstructor(Class.java:643)
at java.lang.Class.getConstructor(Class.java:472)
at android.view.LayoutInflater.createView(LayoutInflater.java:480)
... 22 more
Any idea why?
Try <fragment> tag and name attribute for class name. Also, you've used class name as com.bla.HeaderFragment_ , seems like a typo.
<fragment android:id="#+id/myFragment"
android:name="com.bla.HeaderFragment_"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
More Examples here.

zxing android integration crash on some devices , he following classes could not be instantiated: - com.google.zxing.client.android.ViewfinderView

I have integrated Zxing as Library and used in my application. I am calling by
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_FORMATS", "CODE_39");
intent.putExtra("SAVE_HISTORY", false);
startActivityForResult(intent, 0);
It works fine on most devices but on Some devices like HTC Desire ,GT-I9000 . I am receiving below Error.
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.Armacell.login/com.google.zxing.client.android.CaptureActivity}:
android.view.InflateException: Binary XML file line #25: Error
inflating class com.google.zxing.client.android.ViewfinderView at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:123) at
android.app.ActivityThread.main(ActivityThread.java:4627) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:521) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) at
dalvik.system.NativeStart.main(Native Method) Caused by:
android.view.InflateException: Binary XML file line #25: Error
inflating class com.google.zxing.client.android.ViewfinderView at
android.view.LayoutInflater.createView(LayoutInflater.java:513) at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) at
android.view.LayoutInflater.inflate(LayoutInflater.java:407) at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
at android.app.Activity.setContentView(Activity.java:1647) at
com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:160)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more Caused by: java.lang.reflect.InvocationTargetException at
com.google.zxing.client.android.ViewfinderView.(ViewfinderView.java:62)
at java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:446) at
android.view.LayoutInflater.createView(LayoutInflater.java:500) ... 21
more Caused by: android.content.res.Resources$NotFoundException:
Resource is not a Drawable (color or path):
TypedValue{t=0x1/d=0x7f070012 a=-1 r=0x7f070012} at
android.content.res.Resources.loadDrawable(Resources.java:1681) at
android.content.res.TypedArray.getDrawable(TypedArray.java:601) at
android.view.View.(View.java:1895) at
android.view.View.(View.java:1844) ... 25 more
I am also receiving this warning on Capture.xml file in zxing source -
"The following classes could not be instantiated:
- com.google.zxing.client.android.ViewfinderView"
I am requesting all to help in this case. Thanks in Advance.
This is all wrong -- you're including our Android code in your app. It's not necessary, not encouraged, and you haven't done it correctly either. Please delete all code you copied from android/ into your project.
(In fact we strongly discourage you from copying and pasting like you have.)
Instead you should just be using code in android-integration and nothing else. You're not actually using the integrator code even!
Please start over from: http://code.google.com/p/zxing/wiki/ScanningViaIntent
I have Got Solution on My Own.
The Issue is regarding Culture. I have change default "values". make "values-de" to "values". That crashes Zxing on device that have German culture.
I don't know why it was working but now i have made english as default and it working now :)

Why is my app trying to use drawable-mdpi/title_bar_shadow.9.png?

The app works fine on HPDI and MDPI, but when run in an LDPI (v2.0) emulator, I get the exception and stack trace below.
Why is it looking for this image? (it's not referenced in my application, I've checked). The starter activity has disabled the title bar in any case.
If the OS expects this image, why is it not present?
Why is the exception relating to an MPDI image, when the emulator is LDPI?
04-20 11:35:19.432: ERROR/AndroidRuntime(236): Uncaught handler: thread main exiting due to uncaught exception
04-20 11:35:19.502: ERROR/AndroidRuntime(236): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spondle/com.spondle.EventsActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4310)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
at android.app.Activity.setContentView(Activity.java:1622)
at com.spondle.EventsActivity.onCreate(EventsActivity.java:38)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.ImageView.<init>(ImageView.java:105)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 23 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-mdpi/title_bar_shadow.9.png from drawable resource ID #0x7f02002a
at android.content.res.Resources.loadDrawable(Resources.java:1710)
at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
at android.widget.ImageView.<init>(ImageView.java:115)
... 27 more
Caused by: java.io.FileNotFoundException: res/drawable-mdpi/title_bar_shadow.9.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:391)
at android.content.res.Resources.loadDrawable(Resources.java:1702)
... 29 more
If the OS expects this image, why is it not present?
Why is the exception relating to an MPDI image, when the emulator is LDPI?
If the requested resource (title_bar_shadow.9.png) is not present in drawable-ldpi (and it wasn't until Android 2.3), Android will try to find the best match (drawable-mdpi will be the next folder to search in). Anyway, the file will not be found there either (again, it was not there until Android 2.3). So the next step would be to search for it in drawable-hdpi (where it can be found). But apparently the search stops on drawable-mdpi (which is strange... maybe a bug in Android 2.1? you could try Android 2.2 emulator)
Why is it looking for this image? (it's not referenced in my application, I've checked). The starter activity has disabled the title bar in any case.
This image (shadow) is not used by the title bar. It is displayed UNDER the title bar.
To make it disappear, you have to create your own theme, like this:
<style
name="Theme"
parent="android:Theme.NoTitleBar">
<item
name="android:windowContentOverlay">#null</item>
</style>
I solved this problem making a copy of the images from drawable-ldpi/mdip/hdpi to a drawable (only drawable) folder. Put in this folder your low resolution images.
You don't need to have a title_bar_shadow.9.png file on these folders.

Categories

Resources