How to solve 'failed linking file resources' error? - android

I'm getting a build error: 'failed linking file resources' in Android Studio. How do I solve this?

This is the problem:
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginBottom="75dp"
android:gravity="center"
android:textSize="400sp"
android:removeView=""
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
android:removeView doesn't exist. Remove that line.

there is some thing wrong in one of the XML files
you can go back and check your recently added/changed XML
for me it was spelling mistake(vible instead of visible)
<ProgressBar
android:id="#+id/prog_bar"
style="#style/ProgressBar.Green"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1"
**android:visibility="vible"**/>

Related

Android Studio shows wrong layout in layout preview (ActionBarOverlayLayout?!)

I have a nice FrameLayout as main container and some other views inside it's hierarchy.
But the preview shows a simple ActionBarOverlayLayout.
What is that? Why is it here?
I have Android Studio 3.0.0
I have tried:
Restart Android Studio. Refresh the preview by resizing. Changed the preview device, changed the SDK of the preview, changed the blueprint\design options, pressed "force refresh layout" Button.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="match_parent"
android:layout_height="#dimen/walk_list_item_height"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:layout_heightPercent="25%"
app:layout_marginLeftPercent="0%"
app:layout_marginTopPercent="0%"
app:layout_widthPercent="100%"
app:riv_corner_radius="#dimen/corner_radius"
android:id="#+id/walk_iv" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/gradient"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<TextView
android:id="#+id/walk_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="16dp"
android:text="New Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_duration_icon" />
<TextView
android:id="#+id/duration_tv"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:gravity="center|left"
android:text="TextView"
android:textColor="#fff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_marker"
android:layout_marginLeft="16dp" />
<TextView
android:id="#+id/stops_tv"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
That is because there is a broken build in your earlier build. It is coming from the intermediate files which is because the files are not proper in your xml files. There might be a broken link or a - in the drawables names.
Until you resolve this you cannot proceed to see the layout of your app in the layout-editor.
Moreover Android Studio will not show you any error in the error log or any other terminal.
Start from the styles/themes of the app, it might contain something which is missing from the gradle or resources of the project. Due to the support library still in the project it partially showcases it as missing control of XML files, but it will not let you load the xml editor visually for the project.
You have see that by yourself, start first from drawables and then move to values folder, if not check your gradle and then come back to Java files for the error.
Had to raise
buildToolsVersion to 26.0.0
previous was bugged (25.0.2)
I faced the same problem and, In my case, it was simpler than that. I just received a warning message recommending to remove the explict reference to the BuildToolsVerison from build.gradle file so I just did it, then saved all file, Menu >> Run >> Make a project and it worked fine.

No resource identifier found for attribute 'layout_constraintBottom' in package

I'm trying to build a simple android app in Android Studio 2.3.2, but I'm getting the following error for component I add to the app: "No resource identifier found for attribute 'layout_constraintBottom' in package 'com..."
I researched this problem and found that some people are getting a similar error. However, the answers are suggesting to add "compile 'com.android.support.constraint:constraint-layout:1.0.2'" to the gradle.build file. When I looked there, the line is already in place.
Here is a snippet of my code:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_menu"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.nmeneses.scorekeeper.MainMenu"
tools:showIn="#layout/activity_main_menu">
<Button
android:id="#+id/button3"
android:layout_width="128dp"
android:layout_height="79dp"
android:layout_marginBottom="50dp"
android:layout_marginLeft="39dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="Teams"
android:textSize="23dp"
app:layout_constraintBottom="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.066"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
Any help would be greatly appreciated. If you need more info, please let me know.
AFAIK there is no attribute layout_constraintBottom in ConstraintLayout. There is layout_constraintBottom_toTopOf and layout_constraintBottom_toBottomOf.
I suggest that you use the following line instead:
app:layout_constraintBottom_toBottomOf="parent"

i have error in R.java?

Please help me ,I convert the file PSD to Android xml file by exportkit ,Then came the mistakes
How do I remove these mistakes ?
and What is the reason for mistakes ?
[1]: http://i.stack.imgur.com/N3oDr.png
[2]: http://i.stack.imgur.com/rDyhn.png
[3]: http://i.stack.imgur.com/dZ0qc.png
<ImageView android:id="#+id/layer_2"
android:src="#drawable/layer_2"
android:contentDescription="#string/ek_img_content"
android:layout_marginStart="0dp"
android:layout_marginTop="219dp"
android:layout_width="550dp"
android:layout_height="398dp" />
<TextView android:id="#+id/first_app"
android:fontFamily="Tahoma"
android:layout_gravity="center_vertical|end"
android:gravity="end"
android:textSize="34sp"
android:textColor="#color/first_app_color"
android:layout_marginStart="164dp"
android:layout_marginTop="86dp"
android:layout_width="148dp"
android:layout_height="52dp"
android:text="#string/first_app_string"
/>
<TextView android:id="#+id/good_luck"
android:fontFamily="Tahoma"
android:layout_gravity="center_vertical|end"
android:gravity="end"
android:textSize="34sp"
android:textColor="#color/first_app_color"
android:layout_marginStart="142dp"
android:layout_marginTop="684dp"
android:layout_width="171dp"
android:layout_height="52dp"
android:text="#string/good_luck_string"
/>
</RelativeLayout>
</ScrollView>
</HorizontalScrollView>
Try this:
.xml file name should be small letters only allowed
Change: App1.xml to app.xml
Try Clean Project and Rebuilt your project.

Error in ImageButtons at src:"#drawable/..." Top level element is not completed

Everytime I put a #drawable item it appears underlined in red. It worked before but I pressed one of the options in the light bulb that appears next to the line and then all drawables became errors. I can't find the problem... I'm working with Android Studio. I tried to rebuild, clean, reimport... and nothing solves the problem.
My code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/back"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/backstate" /> /////////////////ERROR in "#drawable/backstate" (Underlined in red)
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/blanc"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/blancstate"/> /////////////////SAME ERROR
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/groc"
android:layout_marginTop="50dp"
android:layout_marginRight="20dp"
android:background="#null"
android:src="#drawable/grocstate"/> /////////////////SAME ERROR
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/taronja"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/taronjastate"/> /////////////////SAME ERROR
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/vermell"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="#null"
android:src="#drawable/vermellstate"/> /////////////////SAME ERROR
</TableRow>
</TableLayout>
All xml states are correct, layouts are well formed, i didn't change anything from the code, and by clicking that option that I didn't remember, all drawables started to give me errors.
ERROR DESCRIPTION: Top level element is not completed. Valid XML document must have a root tag.
Anyway the document is well formed... And it says the same error each time I write "#drawable/..."
EDIT: I found the origin of the problem. android namespace is the problem, if I change it for tools namespace it works. tools:src="#drawable/vermellstate" for example.
Can anyone help me please?
Try this:
Select item that is displaying error, then press alt + enter on the drawable item which calls error (for example:"#drawable/vermellstate") and select "Uninject language/reference"
Could be the case that you injected language by mistake.
If you are using Android Studio right click the code in question then->Local History->Show History and revert to a time prior to "Language Injection Configuration Update" .
Hope it helped,
Best of luck !

Cannot resolve symbol 'container' - Android Studio

I just created a new projet, building some layouts, writing some code. Everything was fine except I got this error as shown in the picture below.
I tried to remove and type it again and when typing 'R.id.', there was no 'container' showing up in the list. So that means theres no problem with my R file, just that the 'container' word lost somewhere.
Those code above are actually default code in onCreate() method in your main activity everytime you create a new project in Android Studio. (I actually tried to create a new project to compare and yes it's the same, and without error as it's brand new.).
All I did was comment out the if statement block so the error goes away, and the application has run just fine on the emulator. I just don't know why I got that problem and how I can handle it as I may need to do that in the future. Thank you!
Edit after #Raghunandan has mentioned: Below is my xml.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/provide_information"
android:id="#+id/provideInfoButton"
android:layout_alignParentTop="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/take_picture"
android:id="#+id/takePictureButton"
android:layout_below="#+id/provideInfoButton"
android:layout_alignParentLeft="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_below="#+id/takePictureButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/classNameTextView"
android:layout_above="#+id/personNametextView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginBottom="38dp"
android:layout_above="#+id/emailTextView"
android:layout_alignLeft="#+id/emailTextView"
android:id="#+id/personNameTextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/emailTextView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/classNameTextView"
android:layout_marginBottom="82dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/send_button"
android:id="#+id/sendButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
The reason is that I changed the root layout to RelativeLayout (the default of Android Studio was FrameLayout which has an id of "container"). My bad :). Thanks for mentioning about posting the xml file. I have not noticed that as I'm not as familiar with Android Studio as with Eclipse yet.

Categories

Resources