为什么我得到"包R不存在"错误?

时间:2017-03-15 10:40:21

标签: java android

我有几个月前完成的小项目,并将其保留在我的git帐户中。

今天我已经在本地下载了这个项目并尝试启动,但是出现了这样的错误

Error:(18, 19) error: package R does not exist

我尝试了cleanrebuild,但它没有帮助

我的日志看起来像这样

Information:Gradle tasks [:app:assembleDebug]
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java
    Error:(7, 39) error: cannot find symbol class R
Error:(18, 19) error: package R does not exist
    Error:(21, 79) error: package R does not exist
    Error:(22, 79) error: package R does not exist
    Error:(31, 17) error: package R does not exist
    Error:(176, 51) error: package R does not exist
    Error:(178, 53) error: package R does not exist
    Error:(179, 51) error: package R does not exist
    Error:(181, 53) error: package R does not exist
    Error:(182, 51) error: package R does not exist
    Error:(184, 53) error: package R does not exist
    Error:(185, 51) error: package R does not exist
    Error:(187, 53) error: package R does not exist
    Error:(189, 51) error: package R does not exist
    Error:(192, 62) error: package R does not exist
    Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
    Compilation failed; see the compiler error output for details.
    Information:BUILD FAILED
    Information:Total time: 2.421 secs
    Information:98 errors
    Information:0 warnings
    Information:See complete output in console

我的编译器错误输出如下所示

/Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:7: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:17: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:22: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentVideo.java:6: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:15: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivitySplash.java:12: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:7: error: cannot find symbol
    import com.example.aleksey.videoviewer.R;
    ^
    symbol:   class R
    location: package com.example.aleksey.videoviewer
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:18: error: package R does not exist
    setTheme(R.style.AppTheme_Dark);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:21: error: package R does not exist
    Preference prefShareKey      = (Preference) findPreference(getString(R.string.pref_share_key));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:22: error: package R does not exist
    Preference prefRateReviewKey = (Preference) findPreference(getString(R.string.pref_rate_review_key));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:31: error: package R does not exist
    return R.xml.pref_about;
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:36: error: package R does not exist
    if(preference.getKey().equals(getString(R.string.pref_share_key))) {
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:40: error: package R does not exist
    getString(R.string.subject));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:41: error: package R does not exist
    shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.message) +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:42: error: package R does not exist
    " " + getString(R.string.googleplay_url));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:43: error: package R does not exist
    startActivity(Intent.createChooser(shareIntent, getString(R.string.share_to)));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:44: error: package R does not exist
    }else if(preference.getKey().equals(getString(R.string.pref_rate_review_key))) {
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:47: error: package R does not exist
    getString(R.string.googleplay_url)));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:56: error: package R does not exist
    overridePendingTransition(R.anim.open_main, R.anim.close_next);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityAbout.java:56: error: package R does not exist
    overridePendingTransition(R.anim.open_main, R.anim.close_next);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:61: error: package R does not exist
    setContentView(R.layout.activity_home);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:63: error: package R does not exist
    layoutList = (FrameLayout) findViewById(R.id.fragment_container);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:64: error: package R does not exist
    toolbar = (Toolbar) findViewById(R.id.toolbar);

      /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:70: error: package R does not exist
    channelNames = getResources().getStringArray(R.array.channel_names);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:71: error: package R does not exist
    channelId = getResources().getStringArray(R.array.channel_id);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:72: error: package R does not exist
    videoTypes = getResources().getStringArray(R.array.video_types);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:87: error: package R does not exist
    .withHeaderBackground(R.drawable.main_icon)
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:127: error: package R does not exist
    .replace(R.id.fragment_container, fragment)
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:133: error: package R does not exist
    overridePendingTransition(R.anim.open_next, R.anim.close_main);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:133: error: package R does not exist
    overridePendingTransition(R.anim.open_next, R.anim.close_main);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:100: error: package R does not exist
    .withName(getString(R.string.about))
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:156: error: package R does not exist
    .replace(R.id.fragment_container, fragment)
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:163: error: package R does not exist
    Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:186: error: package R does not exist
    String.format(getString(R.string.error_player),
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:208: error: package R does not exist
    getMenuInflater().inflate(R.menu.activity_home, menu);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:215: error: package R does not exist
    case R.id.menuAbout:
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:219: error: package R does not exist
    overridePendingTransition(R.anim.open_next, R.anim.close_main);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:219: error: package R does not exist
    overridePendingTransition(R.anim.open_next, R.anim.close_main);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/activities/ActivityHome.java:278: error: package R does not exist
    (FragmentVideo) getFragmentManager().findFragmentById(R.id.video_fragment_container);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:78: error: package R does not exist
    View view = inflater.inflate(R.layout.fragment_video_list, container, false);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:86: error: package R does not exist
    view.findViewById(R.id.ultimate_recycler_view);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:87: error: package R does not exist
    mLblNoResult                = (TextView) view.findViewById(R.id.lblNoResult);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:88: error: package R does not exist
    mLytRetry                   = (LinearLayout) view.findViewById(R.id.lytRetry);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:89: error: package R does not exist
    mPrgLoading                 = (CircleProgressBar) view.findViewById(R.id.prgLoading);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:90: error: package R does not exist
    AppCompatButton btnRetry    = (AppCompatButton) view.findViewById(R.id.raisedRetry);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:93: error: package R does not exist
    mPrgLoading.setColorSchemeResources(R.color.accent_color);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:112: error: package R does not exist
    .inflate(R.layout.progressbar, null));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:120: error: package R does not exist
    .inflate(R.layout.progressbar, null));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:189: error: package R does not exist
    Utils.PARAM_KEY_YOUTUBE + getResources().getString(R.string.youtube_apikey) + "&" +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:198: error: package R does not exist
    Utils.PARAM_KEY_YOUTUBE + getResources().getString(R.string.youtube_apikey) + "&" +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:315: error: package R does not exist
    msgSnackBar = getResources().getString(R.string.no_internet_connection);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:317: error: package R does not exist
    msgSnackBar = getResources().getString(R.string.response_error);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:350: error: package R does not exist
    Utils.PARAM_KEY_YOUTUBE+getResources().getString(R.string.youtube_apikey)+"&"+
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:426: error: package R does not exist
    msgSnackBar = getResources().getString(R.string.no_internet_connection);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:428: error: package R does not exist
    msgSnackBar = getResources().getString(R.string.response_error);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentChannelVideo.java:502: error: package R does not exist
    case R.id.raisedRetry:
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/fragments/FragmentVideo.java:21: error: package R does not exist
    initialize(getResources().getString(R.string.youtube_apikey), this);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:45: error: package R does not exist
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_video_list, parent, false);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:74: error: package R does not exist
    R.mipmap.empty_photo, R.mipmap.empty_photo));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:74: error: package R does not exist
    R.mipmap.empty_photo, R.mipmap.empty_photo));
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:109: error: package R does not exist
    txtTitle = (TextView) v.findViewById(R.id.txtTitle);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:110: error: package R does not exist
    txtDuration = (TextView) v.findViewById(R.id.txtDuration);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:111: error: package R does not exist
    txtPublished = (TextView) v.findViewById(R.id.txtPublishedAt);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/adapters/AdapterList.java:112: error: package R does not exist
    imgThumbnail = (ImageView) v.findViewById(R.id.imgThumbnail);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:141: error: package R does not exist
    timeAgo = dim + " " + ctx.getResources().getString(R.string.date_util_unit_minutes);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:143: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:144: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_hour);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:147: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:149: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_hour);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:151: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:153: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_hours);

    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:158: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_day);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:161: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_days);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:164: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_daya);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:167: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_day);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:169: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " "+
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:170: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_month);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:178: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " "+
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:182: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_year);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:184: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_almost) + " 2 " +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:185: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_years);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:187: error: package R does not exist
    timeAgo = ctx.getResources().getString(R.string.date_util_prefix_about) + " " +
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:189: error: package R does not exist
    ctx.getResources().getString(R.string.date_util_unit_years);
    ^
    /Users/admin/UserData/androidProjects/YoutubeClient/app/src/main/java/com/example/aleksey/videoviewer/activities/utils/Utils.java:192: error: package R does not exist
    return timeAgo + " " + ctx.getResources().getString(R.string.date_util_suffix);
    ^
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    97 errors

    :app:compileDebugJavaWithJavac FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 3.564 secs
    Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources,

根据此输出

Note: Some input files use or override a deprecated API.

我在这个项目中使用的API已被弃用,但我怎么知道哪一个以及如何解决它?

我也有这样的警告

Invalid VCS root mapping
                The directory /Users/admin is registered as a Git root, but no Git repositories were found there.

但我认为它不会直接影响R类错误。

我做错了什么?

2 个答案:

答案 0 :(得分:1)

一旦发生在我身上。原因是我从另一个项目中复制了一个java文件并将其粘贴到项目中。然后我开始收到错误' R不存在'。这背后的原因是我从不同的项目中复制了一个java文件,并且该项目中的R文件可以在不同的包中使用。我做了什么我刚刚导入了属于我的包的R文件。并做了。您需要确保是否要复制项目中的任何活动文件,请根据您的项目包更新R的包。 注意:您可以做的另一件事就是转到所有可用的import语句区域(在java文件的顶部)。删除R&#39文件的import语句,然后再次导入。它会导入你的包R文件。希望它会帮助你。

答案 1 :(得分:0)

迟到聚会了,但这是在向我的项目添加新活动之后在Android Studio 3.0中发生的。原来该活动的包裹名称错误(d'哦!不确定是我的错还是AS的错)。更正java文件顶部的程序包名称并将其移至正确的文件夹即可解决此问题。