0

I have created a new project and after build is done, when I tried opening activity_main.xml it is giving me following Rendering error: Error in activity_main.xml

Can anyone tell, what's the possible reason behind this and how to solve this problem? I have just started learning android , but in the very beginning I am getting stuck.

As asked, adding my app's build.gradle and layout.xml :

Build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "28.0.0"
    defaultConfig {
        applicationId "com.chanfool21.firstapp"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.+'
    testCompile 'junit:junit:4.12'
}

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.chanfool21.firstapp.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>
Chanfool21
  • 57
  • 9

1 Answers1

0

just do a gradle build if that doesn't work clean/rebuild project if also that dosen't work invalidate cach restart

himel
  • 500
  • 5
  • 14
  • Hi Himel, I did all the steps as you suggested but it still not working, showing same error messages. Null Pointer exceptions and other messages same as what above picture shows – Chanfool21 Jun 10 '18 at 07:12