IDE:安卓工作室
- 创建新项目
- 将 appcompat 的 .jar 复制到 /lib/
- 在项目设置中设置依赖项
- 将 compile "com.android.support:appcompat-v7:18.0.+" 添加到 build.gradle
添加以下代码:
公共类 MainActivity 扩展 ActionBarActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); actionBar.setTitle("hello"); }
没事了。获取下一个错误:
"Gradle: A problem occurred configuring project ':MyApplication'.
> Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration ':MyApplication:_DebugCompile'.
> Could not find any version that matches com.android.support:appcompat-v7:18.0.+.
Required by:
MyApplicationProject:MyApplication:unspecified"
怎么修?我忘了做什么?