当我尝试导入错误"Cannot resolve the symbol ActionBarActivity"
时。
我阅读了有关同一问题的问题,并阅读了答案,并试图解决该问题,但无济于事。
我正在使用Android Studio版本3.2.1.0
这是我的构建gradle文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
MainActivity文件:
package com.example.android.justjava;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.TextView;
/**
* This app displays an order form to order coffee.
*/
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* This method is called when the order button is clicked.
*/
public void submitOrder(View view) {
display(1);
}
/**
* This method displays the given quantity value on the screen.
*/
private void display(int number) {
TextView quantityTextView = (TextView) findViewById(
R.id.quantity_text_view);
quantityTextView.setText("" + number);
}
}
答案 0 :(得分:0)
“无法解析符号ActionBarActivity”
这是因为ActionBarActivity
已被弃用,并已在最近的支持库中删除。
您需要从ActionBarActivity
迁移并使用AppCompatActivity
。