1

My error in Android Studio is that it give red R (R.layout.activity_main) in MainActivity.java file. I trid my best to solve error by cleaning and rebilding the projects but can't.

(Android Studio marks R in red with error message "cannot resolve symbol R", but build succeeds)

My Mainactivity.java code is here:

package com.example.zeeshan.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
Timer timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
timer =new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
finish();
}
}, 5000);
}
}

Following is my AndroidManfifest.xml code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zeeshan.myapplication">
<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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Main2Activity"></activity>
</application>
</manifest>

I was expecting that my app launch succesfuuly but it does not .. plz help me

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Possible duplicate of ["cannot resolve symbol R" in Android Studio](https://stackoverflow.com/questions/17054000/cannot-resolve-symbol-r-in-android-studio) – Zoe May 19 '19 at 10:00

1 Answers1

0

Try restarting your android studio, if it doesn't fix your problem. Look at your imports you might have called the same import twice if so remove one of the imports.

Gal
  • 422
  • 5
  • 21