I've been trying to get this widget working in my Android project: https://code.google.com/p/android-coverflow/source/browse/
It's called Coverflow, and it kind of replaces the old Gallery widget. Implementing it seemed pretty straightforward until I got the error:
08-16 17:33:08.289: E/AndroidRuntime(15031): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class pl.polidea.coverflow.CoverFlow
This is the XML file the error is referring to:
<pl.polidea.coverflow.CoverFlow class="pl.polidea.coverflow.CoverFlow"
android:id="#+id/coverflow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip" >
</pl.polidea.coverflow.CoverFlow>
This question has been asked before on StackOverflow but the answer given here: Android coverflow : Error inflating class pl.polidea.coverflow.CoverFlow didn't work for me.
You should Use by this way:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<view class="pl.polidea.coverflow.CoverFlow" xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
coverflow:imageWidth="100dip" coverflow:imageHeight="150dip" android:id="#+id/coverflow" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dip">
</view>
<pl.polidea.coverflow.CoverFlow xmlns:coverflow="http://schemas.android.com/apk/res/pl.polidea.coverflow"
coverflow:imageWidth="100dip" coverflow:imageHeight="150dip" coverflow:withReflection="true"
coverflow:imageReflectionRatio="0.2" coverflow:reflectionGap="2dip" android:id="#+id/coverflowReflect"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" />
<TextView android:text="STATUS" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:padding="5dip" android:id="#+id/statusText"></TextView>
</LinearLayout>
Make sure that "pl.polidea.coverflow.CoverFlow" is your class file(package+java class)...
Else replace "pl.polidea.coverflow.CoverFlow" in your xml with your actual class file having coverflow!!
Related
Can anyone tell me whats wrong with this layout? Because I can't seem to find anything unusual that could cause InflateException. Also I am getting this exception mostly on Samsung Devices, others seem to work more or less fine. Full exception
Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{class name}: android.view.InflateException: Binary XML file line #0: Error inflating {class name}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/loginContainer"
style="#style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0">
<LinearLayout
android:id="#+id/holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:gravity="center"
android:text="#string/window_enter_identifier_greeting_label"
android:textAlignment="center"
android:textSize="26sp" />
<TextView
android:id="#+id/info"
style="#style/AuthenticationTheme"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="#dimen/authentication_margin_from_sides"
android:layout_marginRight="#dimen/authentication_margin_from_sides"
android:gravity="center"
android:text="#string/window_enter_identifier_phone_description_label"
android:textAlignment="center"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/phoneInputHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.custom.authentication.views.IdentifierInputView
android:id="#+id/authenticationInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/authentication_margin_from_sides"
android:layout_marginRight="#dimen/authentication_margin_from_sides" />
</LinearLayout>
</LinearLayout>
<com.custom.authentication.views.BottomButtonsView
android:id="#+id/bottomButtons"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:linkText="#string/window_enter_identifier_login_with_email_button"
app:mainText="#string/Continue" />
</android.support.constraint.ConstraintLayout>
I am inflating this layout in my custom view class like this:
class EnterIdentifierView(context: Context) : ConstraintLayout(context) {
init {
inflate(context, R.layout.view_enter_identifier, this)
}
And creating my custom view like this:
override fun onCreateControllerView(layoutInflater: LayoutInflater, viewParent: ViewGroup) = EnterIdentifierView(layoutInflater.context)
I don't think this is an answer, more of a suggestion, but as I don't have enough reputation have to post it as such.
From my experience when I get this type of error it sometimes indicates an OutOfMemory error, check to make sure your custom classes aren't trying to load any large images etc.
Also check the full Stacktrace carefully, if you have access to one, for any OOMs
I'm very very new to android programming and while trying to run this simple program I get the error: "Unfortunately your app stopped".
So I went and looked in the Logcat file and this is where, I think, the problem is:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.example.tictactoe, PID: 3202
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.tictactoe/org.example.tictactoe.MainActivity}: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.
But looking at my files I don't see where It's missing.
This are the files .xml which I used:
activity_main.xml:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/lib/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context=".TicTacToeActivity">
<fragment
android:id="#+id/main_fragment"
android:name="org.example.tictactoe.MainFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:layout="#layout/fragment_main"/>
</FrameLayout>
fragment_main.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/lib/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/menu_background"
android:elevation="#dimen/elevation_high"
android:orientation="vertical"
android:padding="#dimen/menu_padding"
tools:context=".TicTacToeActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/menu_space"
android:text="#string/long_app_name"
android:textAppearance="?android:textAppearanceLarge"
android:textSize="#dimen/menu_text_size"
/>
<Button
android:id="#+id/continue_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/continue_label"
/>
<Button
android:id="#+id/new_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/new_game_label"
/>
<Button
android:id="#+id/about_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/about_label"
/>
</LinearLayout>
menu_background:
<shape
xmlns:android="http://schemas.android.com/apk/lib/android"
android:shape="rectangle">
<stroke
android:width="#dimen/stroke_width"
android:color="#color/border_color"/>
<solid android:color="#color/field_color"/>
<corners android:radius="#dimen/corner_radius"/>
</shape>
I cannot find where the layout_width attribute is missing.
There are blank spaces in your layout. For example, in fragment_main.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/lib/android "
xmlns:tools="http://schemas.android.com/tools "
Use Find and Replace for " or in your layout.
UPDATE
You have another error in the following xml:
You can't use class="org.example.tictactoe.MainFragment". But you need to use android:name attribute. So, it should be:
<fragment
android:id="#+id/main_fragment"
android:name="org.example.tictactoe.MainFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:layout="#layout/fragment_main"/>
Found another problem in your xml code. Use xmlns:android="http://schemas.android.com/apk/res/android" instead of xmlns:android="http://schemas.android.com/apk/lib/android".
You have a space in "wrap_content " for layout_width and layout_height in MainFragment.
Remove android:layout_gravity="#layout/fragment_main" from activity_main.xml
android:layout_gravity requires specific parameters android:layout_gravity Reference Link
Fragments reference
I realize that there are a lot of questions with titles similar to this one, but I think my problem is one that has not yet been addressed.
I have an existing Android application that is entering the intensive beta-testing phase. To that end, I am attempting to implement Instabug to help out.
This morning, before attempting to implement Instabug, my app worked (in that it launched).
My MainActivity extends android.app.Activity, so I replaced that with InstabugActivity (com.instabug.wrapper.support.activity.InstabugActivity).
My MainActivity is for login/sign up, and then the app transitions to an AppRootActivity, which is an android.support.v7.app.ActionBarActivity. This is because the app has a navigation drawer. So, I changed AppRootActivity to an InstabugActionBarActivity (com.instabug.wrapper.support.activity.InstabugActionBarActivity).
When I run the app in debug mode using an attached device, it works just fine. When I push the app out to my testers via Fabric/Crashlytics, the app crashes at launch.
From what I can tell, these are the important error messages I'm getting:
java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.company.app/com.company.app.MainActivity}:
android.view.InflateException: Binary XML file line #14:
Error inflating class fragment
Caused by:
android.view.InflateException: Binary XML file line #14:
Error inflating class fragment
at com.company.app.MainActivity.onCreate(Unknown Source)
Caused by:
android.app.Fragment$InstantiationException:
Trying to instantiate a class
com.company.app.NavigationDrawerFragment
that is not a Fragment
at com.company.app.MainActivity.onCreate(Unknown Source)
Caused by: java.lang.ClassCastException
at com.company.app.MainActivity.onCreate(Unknown Source)
Ok, now here's the weird thing. MainActivity is never tied to NavigationDrawerFragment. Never.
I have no idea why the app is trying to instantiate NavigationDrawerFragment when the app is launching.
Even still, though, NavigationDrawerFragment extends MyFragment which extends Fragment (android.support.v4.app.Fragment).
I am really, really lost here. I'd love to use Instabug, because their product on iOS is really nice and impressive, but I can't figure this out!
Edit
Here's the XML layout for ActivityMain:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/main_activity_background"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
>
<View
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
/>
<ImageView
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:src="#drawable/main_activity_logo"
/>
<View
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
/>
<TextView
android:id="#+id/main_activity_tag_line_text_view"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:text="#string/tag_line"
android:textColor="#color/off_white"
android:textSize="20dp"
/>
<ImageButton
android:id="#+id/main_activity_sign_up_with_Facebook_button"
android:background="#drawable/main_activity_facebook_button_shape"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/main_activity_vertical_button_margin"
android:layout_marginTop="#dimen/main_activity_vertical_button_margin"
android:layout_width="wrap_content"
android:paddingBottom="#dimen/main_activity_facebook_sign_up_button_vertical_padding"
android:paddingLeft="#dimen/main_activity_facebook_sign_up_button_horizontal_padding"
android:paddingRight="#dimen/main_activity_facebook_sign_up_button_horizontal_padding"
android:paddingTop="#dimen/main_activity_facebook_sign_up_button_vertical_padding"
android:src="#drawable/main_activity_facebook_sign_up"
/>
<Button
android:id="#+id/main_activity_sign_up_button"
android:background="#drawable/sign_up_button_shape"
android:gravity="center"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/main_activity_vertical_button_margin"
android:layout_marginTop="#dimen/main_activity_vertical_button_margin"
android:layout_width="wrap_content"
android:text="#string/sign_up_title"
android:textColor="#color/dark_gray"
android:textSize="#dimen/login_button_text_size"
/>
<Button
android:id="#+id/main_activity_login_button"
android:background="#drawable/main_activity_login_button_shape"
android:gravity="center"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/main_activity_vertical_button_margin"
android:layout_marginTop="#dimen/main_activity_vertical_button_margin"
android:layout_width="wrap_content"
android:text="#string/login_title"
android:textColor="#color/gold"
android:textSize="#dimen/login_button_text_size"
/>
<TextView
android:id="#+id/main_activity_disclaimer_text_view"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_width="wrap_content"
android:text="#string/disclaimer"
android:textColor="#color/off_white"
android:textSize="12dp"
/>
</LinearLayout>
I downloaded sample android carousel demo source code in the below link http://www.codeproject.com/Articles/146145/Android-3D-Carousel#xx4884593xx
The main.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pj="http://schemas.android.com/apk/res/carousel.main"
xmlns:bm="carousel.main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/back"
android:orientation="vertical" >
<TextView
android:id="#+id/selected_item"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:background="#1E1921"
android:text="text"
android:textColor="#A85E4F"
android:textStyle="normal"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="top"
android:padding="5dip" >
<carousel.Carousel
android:id="#+id/carousel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animationDuration="200"
pj:Items="#array/entries"
pj:SelectedItem="0"
pj:UseReflection="true" />
</LinearLayout>
</LinearLayout>
However I'm now getting the following errors:
Description Resource Path Location Type
error: No resource identifier found for attribute 'UseReflection' in package 'carousel.main' main.xml
Suspicious namespace: should start with http:// main.xml
Each time I try and clean the project it deletes the R.file. I've tried changing the package name, and pasting all the contents again but that hasn't solved the problem.
I found where the problem was.
In the root of the xml:
xmlns:pj="http://schemas.android.com/apk/res/package_with_calling_class"
xmlns:bm="package_with_calling_class"
package_with_calling_class = the class which might be the main activity where the onCreate() is being called. In my case it was platinum.platinumstars
setContent(R.layout.main)
When I am launching my application, I am getting the error:
04-29 10:20:15.655: E/AndroidRuntime(24548): android.view.InflateException: Binary XML file line #2: Error inflating class com.mobeta.android.dslv.DragSortListView
Here is my XML file:
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="7dp"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:layout_margin="0dp"
android:dividerHeight="5dp"
dslv:drag_enabled="true"
dslv:collapsed_height="2dp"
dslv:drag_scroll_start="0.33"
dslv:max_drag_scroll_speed="0.5"
dslv:float_alpha="0.6"
dslv:slide_shuffle_speed="0.3"
dslv:track_drag_sort="false"
dslv:use_default_controller="true"
dslv:sort_enabled="false"
dslv:remove_enabled="true"
dslv:remove_mode="flingRemove"
android:background="#E5E5E5" />
Does anyone know whats causing the issue? When I attempt to specify the full url "http://schemas.android.com/apk/res/com.mobeta.android.demodslv", the project does not compile.
change xmlns:dslv="http://schemas.android.com/apk/res-auto"
to below line
xmlns:dslv="http://schemas.android.com/apk/lib/com.mobeta.android.dslv"