2

I am currently working on an Android UI, and run in to the following issue.

enter image description here

Base on the android.support.design.widget.AppBarLayout note I am assuming that this is issue with the Gradle. I also am unable to resolve following issue.

enter image description here

Below is the gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "shapetheworld.application.shapetheworld"
        minSdkVersion 18
        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'
        }
    }
}

repositories {
    maven { url 'https://jitpack.io' }

}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Below is the activity_main.xml file

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="shapetheworld.application.shapetheworld.MainActivity"
    tools:layout_editor_absoluteY="25dp">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main" />

</android.support.constraint.ConstraintLayout>

Note: If it matter, I am using Android Studio 3.1.4

Also some of the references suggest that the issue might be in the style.xml thus file can be found below.

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

References:

Mahendra Gunawardena
  • 1,956
  • 5
  • 26
  • 45
  • 1
    You should have same version for all the support libraries Try using com.android.support:appcompat-v7:27.1.0 – Shivam Pokhriyal Aug 19 '18 at 16:15
  • @ShivamPokhriyal, thank you for the hint, your suggestion plus changing the `compileSdkVersion` and `targetSdkVersion` to 27 worked. Post this as a solution so I can accept the answer – Mahendra Gunawardena Aug 19 '18 at 16:32

1 Answers1

3

You need to have same version for all the support libraries you are using. For now, You can replace this line

implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

with

implementation 'com.android.support:appcompat-v7:27.1.0'

Also change your compileSdkVersion and targetSdkVersion version to 27.

Mahendra Gunawardena
  • 1,956
  • 5
  • 26
  • 45
Shivam Pokhriyal
  • 1,044
  • 11
  • 26