Cannot Resolve symbol R

后端 未结 8 1817
礼貌的吻别
礼貌的吻别 2021-01-18 07:02

I was working on Android Studio for adding a short toast message.(I was making an Android Wear Application)

I couldn\'t know why this code has error on \'symbol R\'

相关标签:
8条回答
  • 2021-01-18 07:31

    It happens if your class is missing the link of R.Class which you may have to import. So, Before starting the class you can simply start by

    import Your_Package_name.R;

    E.g.

    import com.example.myproject.R;

    You can manually write this when Clean/Rebuild project is not the solution.

    Use-case:

    import javax.crypto.spec.SecretKeySpec;
    import javax.net.ssl.HttpsURLConnection;
    import com.example.jsonwebservice.R;
    

    This worked for me.

    0 讨论(0)
  • 2021-01-18 07:32

    The thing that finally did the trick for me was looking at the "event log" tab in Android Studio where I saw:

    Frameworks detected: Android framework is detected in the project Configure

    clicking on "Configure" set the AndroidManifest.xml as configuration-file of the project (identified it as "android") and only then all the "R" errors went away and I was able to compile & run.

    Before doing that - all the actions I've tried such as: "clean", "rebuild" and restarting Android studios - didn't work.

    0 讨论(0)
提交回复
热议问题