title: How to determine why the Android build error "failed linking file resources" is happening?
body: <p>My Android Studio project is throwing out this error. It came all of a sudden. I've no idea what this is.</p>
  
  <p>I've tried every possible ways but its not working at all. It was working fine but suddenly when I tried to test the app in the phone. It showed me this error. I have already rebuild the project and restarted Android Studio I've tried every possible solution on the internet but none of them worked for me.</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:processDebugResources'.
  &gt; Android resource linking failed
    Output:  C:\Charcha2\app\src\main\res\layout\activity_main.xml:16: error: attribute fabAttached (aka global.alyssum.charcha:fabAttached) not found.
    error: failed linking file resources.
  
    Command: C:\Program Files\android-studio\gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\139903147407266fe3b81c96769c0caf\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
            C:\ANDROID\NEWFOLDER\SDK\platforms\android-28\android.jar\
            --manifest\
            C:\Charcha2\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
            -o\
            C:\Charcha2\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
            -R\
            @C:\Charcha2\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
            --auto-add-overlay\
            --java\
            C:\Charcha2\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
            --custom-package\
            global.alyssum.charcha\
            -0\
            apk\
            --output-text-symbols\
            C:\Charcha2\app\build\intermediates\symbols\debug\R.txt\
            --no-version-vectors
    Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
    Output:  C:\Charcha2\app\src\main\res\layout\activity_main.xml:16: AAPT: error: attribute fabAttached (aka global.alyssum.charcha:fabAttached) not found.
  
    error: failed linking file resources.
    Command: C:\Program Files\android-studio\gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\139903147407266fe3b81c96769c0caf\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
            C:\ANDROID\NEWFOLDER\SDK\platforms\android-28\android.jar\
            --manifest\
            C:\Charcha2\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
            -o\
            C:\Charcha2\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
            -R\
            @C:\Charcha2\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
            --auto-add-overlay\
            --java\
            C:\Charcha2\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
            --custom-package\
            global.alyssum.charcha\
            -0\
            apk\
            --output-text-symbols\
            C:\Charcha2\app\build\intermediates\symbols\debug\R.txt\
            --no-version-vectors
    Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  </code></pre>
  
  <p>Here is the main activity XML code.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      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:orientation="vertical"
      tools:context=".MainActivity"&gt;
  
      &lt;androidx.coordinatorlayout.widget.CoordinatorLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
  
          &lt;com.google.android.material.bottomappbar.BottomAppBar
              android:id="@+id/bottomAppBar"
              style="@style/Widget.MaterialComponents.BottomAppBar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              android:backgroundTint="#fff"
              app:fabAttached="true"
              app:fabCradleRoundedCornerRadius="16dp"&gt;
  
              &lt;ImageView
                  android:id="@+id/imageView2"
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:layout_marginStart="30dp"
                  app:srcCompat="@drawable/home" /&gt;
  
  
              &lt;ImageView
                  android:id="@+id/imageView3"
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:layout_marginStart="45dp"
                  app:layout_anchor="@id/bottomAppBar"
                  app:srcCompat="@drawable/deals" /&gt;
  
              &lt;ImageView
                  android:id="@+id/imageView4"
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:layout_marginStart="95dp"
                  app:srcCompat="@drawable/listing" /&gt;
  
  
              &lt;ImageView
                  android:id="@+id/imageView5"
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:layout_marginStart="45dp"
                  app:srcCompat="@drawable/profile" /&gt;
  
  
          &lt;/com.google.android.material.bottomappbar.BottomAppBar&gt;
  
  
          &lt;com.google.android.material.floatingactionbutton.FloatingActionButton
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              app:fabSize="normal"
              android:src="@drawable/addvideo"
              app:backgroundTint="#fff"
              app:layout_anchor="@+id/bottomAppBar"
              android:scaleType="center"
              android:id="@+id/myFab"
              /&gt;
  
          &lt;androidx.appcompat.widget.Toolbar
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:id="@+id/toolBar"
              android:background="@drawable/grey_border_top"&gt;
  
  
              &lt;ImageView
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:src="@drawable/city"
                  android:foregroundGravity="left"/&gt;
  
              &lt;EditText
                  android:layout_width="180dp"
                  android:layout_height="23dp"
                  android:layout_marginStart="40dp"
                  android:background="@drawable/search_border"
                  android:hint="Search videos..."
                  android:padding="3dp"
                  android:textStyle="italic" /&gt;
  
              &lt;ImageView
                  android:layout_width="21dp"
                  android:layout_height="21dp"
                  android:src="@drawable/search"
                  android:layout_marginStart="7dp"
                  /&gt;
  
              &lt;TextView
                  android:id="@+id/changeLang"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="20dp"
                  android:clickable="true"
                  android:onClick="onClick"
                  android:text="Change Language"
                  android:textColor="@android:color/black" /&gt;
  
          &lt;/androidx.appcompat.widget.Toolbar&gt;
  
          &lt;com.google.android.material.tabs.TabLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_marginTop="?attr/actionBarSize"
              android:id="@+id/tab_layout"&gt;
  
          &lt;/com.google.android.material.tabs.TabLayout&gt;
  
  
          &lt;androidx.viewpager.widget.ViewPager
              android:layout_width="match_parent"
              android:layout_marginTop="?attr/actionBarSize"
              android:layout_height="360dp"
              android:id="@+id/viewPager"/&gt;
  
  
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And here is my gradle file</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "global.alyssum.charcha"
          minSdkVersion 21
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support:recyclerview-v7:28.0.0'
      implementation 'com.android.support:cardview-v7:28.0.0'
      implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
      implementation 'com.google.android.material:material:1.0.0-alpha1'
      implementation 'com.google.android.gms:play-services-ads:15.0.0'
      implementation 'com.squareup.picasso:picasso:2.5.2'
      implementation 'com.android.support:design:28.0.0'
      implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
      implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
  }
  </code></pre>
  
  <p>Here is my mainActivity</p>
  
  <pre><code>package global.alyssum.charcha;
  
  
  import android.os.Bundle;
  import android.view.View;
  import android.widget.TextView;
  import android.widget.Toast;
  //import android.widget.Toolbar;
  import com.google.android.material.floatingactionbutton.FloatingActionButton;
  import com.google.android.material.tabs.TabLayout;
  
  import java.util.ArrayList;
  
  import androidx.appcompat.app.ActionBar;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.appcompat.widget.Toolbar;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  import androidx.viewpager.widget.ViewPager;
  import global.alyssum.charcha.adapter.PagerAdapter;
  
  public class MainActivity extends AppCompatActivity {
  
      Toolbar AGS_toolbar;
      TextView AGS_langChangeTextView;
      FloatingActionButton AGS_Fab;
      private TabLayout AGS_tabLayout = null;
      private ViewPager AGS_viewPager = null;
  
      public void onClick(View view) {
  
          Toast.makeText(MainActivity.this, "Language changed.", Toast.LENGTH_SHORT).show();
  
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          AGS_toolbar = (Toolbar) findViewById(R.id.toolBar);
          AGS_langChangeTextView = (TextView)findViewById(R.id.changeLang);
          AGS_Fab = (FloatingActionButton) findViewById(R.id.myFab);
          AGS_tabLayout = (TabLayout) findViewById(R.id.tab_layout);
          AGS_viewPager = (ViewPager) findViewById(R.id.viewPager);
  
  
          final PagerAdapter adapter = new global.alyssum.charcha.adapter.PagerAdapter(getSupportFragmentManager(),AGS_tabLayout.getTabCount());
          AGS_viewPager.setAdapter(adapter);
  
      }
  
  
  }
  </code></pre>
  
  <p>And this is the manifest files.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="global.alyssum.charcha"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".Splash"
              android:theme="@style/splash"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".MainActivity"
              android:theme="@style/splash"&gt;
  
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>