Android 在 Eclipse 中创建新项目后会自动创建“appcompat_v7”项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22240970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:41:39  来源:igfitidea点击:

"appcompat_v7" project is created automatically after creating a new project in Eclipse

androideclipse

提问by Ali

After creating any new android project, Eclipse automatically creates a "appcompat_v7" project without any files under /src. I have no idea how or why Eclipse is creating this project. I am also getting a weird error.

创建任何新的 android 项目后,Eclipse 会自动创建一个“appcompat_v7”项目,/src 下没有任何文件。我不知道 Eclipse 如何或为什么创建这个项目。我也收到一个奇怪的错误。

enter image description here

在此处输入图片说明

As you can see the AndroidManifest.xml exists in the project!

如您所见,项目中存在 AndroidManifest.xml!

EDIT1: After cleaning the project the weird error was gone, but I'd still like to know why the appcompat_v7 is created.

EDIT1:清理项目后,奇怪的错误消失了,但我仍然想知道为什么会创建 appcompat_v7。

EDIT2: I also noticed that Eclipse is automatically creating a new layout, fragment_main.xml, under /res/layout. WHY??

EDIT2:我还注意到 Eclipse 会在 /res/layout 下自动创建一个新布局 fragment_main.xml。为什么??

I have created a new Workspace, and tried it several times. But I still have this problem.

我创建了一个新的工作区,并尝试了几次。但我仍然有这个问题。

EDIT3: If you choose the minimum SDK version after API 14 you won't get this support folder.

EDIT3:如果您选择 API 14 之后的最低 SDK 版本,您将不会获得此支持文件夹。

采纳答案by opus44

I ran into this problem last night. I was doing several things including updating the SDK manager. I had to back off the Android SDK Toolsto Rev. 22.3 and Android SDK Platform-toolsto 19.

我昨晚遇到了这个问题。我做了几件事,包括更新 SDK 管理器。我不得不将Android SDK 工具退回到 Rev. 22.3,将Android SDK Platform-tools退回到 19。

opus44

opus44

回答by Sony

first clean and build the appcompat_v7 project and then clean and build your project. it worked

首先清理并构建 appcompat_v7 项目,然后清理并构建您的项目。有效

回答by maaa

I installed "Android support repository" from Android SDK Manager/Extras and the errors are gone.

我从 Android SDK Manager/Extras 安装了“Android 支持存储库”,错误消失了。

回答by sagar.android

Do as follows to overcome this issue, this works for me. Create project as usual than follow below steps

执行以下操作来克服这个问题,这对我有用。照常创建项目,而不是按照以下步骤操作

Step-1:

Right Click on your Project -> Properties -> Android -> In Library panel, removeappcompat_v7 library, Apply and Ok

右键单击您的项目 -> 属性 -> Android -> 在库面板中,删除appcompat_v7 库,应用并确定

Step-2:

In Project goto res -> values -> style.xml

在项目中转到 res -> values -> style.xml

In line <style name="AppBaseTheme" parent="Theme.AppCompat.Light">changeparent value from Theme.AppCompat.Lightto android:Theme.Light

在线<style name="AppBaseTheme" parent="Theme.AppCompat.Light">更改父值从Theme.AppCompat.Lightandroid:Theme.Light

Step-3:

In Project goto res -> values-v11 -> style.xml

在项目中转到 res -> values-v11 -> style.xml

In line <style name="AppBaseTheme" parent="Theme.AppCompat.Light">changeparent value from Theme.AppCompat.Lightto android:Theme.Holo.Light

在线<style name="AppBaseTheme" parent="Theme.AppCompat.Light">更改父值从Theme.AppCompat.Lightandroid:Theme.Holo.Light

Step-4:

In Project goto res -> values-v14 -> style.xml

在项目中转到 res -> values-v14 -> style.xml

In line <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">changeparent value from Theme.AppCompat.Light.DarkActionBarto android:Theme.Holo.Light.DarkActionBar

在线<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">更改父值从Theme.AppCompat.Light.DarkActionBarandroid:Theme.Holo.Light.DarkActionBar

Step-5:

In Project goto menu -> main.xml removethese lines in menu tag:

在 Project goto menu -> main.xml 中删除menu 标签中的这些行:

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.test.MainActivity" 

and in item tag changethis line from app:showAsAction="never"to android:showAsAction="never"

并在项目标签中将此行从更改app:showAsAction="never"android:showAsAction="never"

In project, goto res -> layout -> delete fragment.xml

在项目中,转到 res -> layout -> delete fragment.xml

Step-6:

In MainActivity extends Activitynot ActionBarActivity and finally your MainActivity.java after remove unnecessary code, looks like this:

在 MainActivity 中扩展 Activity而不是 ActionBarActivity ,最后你的 MainActivity.java 在删除不必要的代码后,看起来像这样:

package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

Enjoy:)

享受:)

回答by George Papatheodorou

import the android project to the workspace from /extras/android/support/ then navigate to your current project and add it as dependency : Project > Properties > Android > Add (the imported project) . You should be able to see a Green tick next to the imported project. Remove the old reference that you lost/deleted. A reference about what this library is can be found here

将 android 项目从 /extras/android/support/ 导入到工作区,然后导航到您当前的项目并将其添加为依赖项:Project > Properties > Android > Add (theimported project)。您应该能够在导入的项目旁边看到一个绿色勾号。删除您丢失/删除的旧参考。可以在此处找到有关此库内容的参考

回答by Mokhtarabadi

I on ubuntu only clean up aappcompat_v7 source code it worked well for me

我在 ubuntu 上只清理了 aappcompat_v7 源代码,它对我来说效果很好