gpt4 book ai didi

java - 无法解析Android Studio中的Symbol v7和appComapat Activity导入

转载 作者:行者123 更新时间:2023-12-03 05:23:30 25 4
gpt4 key购买 nike

我在这个问题上停留了3-4天,并且尝试了所有可能的事情,清除了缓存,清理了项目,但仍然无法在设备上运行。弹出错误,显示无法解决v7.app.appcompatActivity。感谢您的帮助,代码如下:
包com.edunomics.flashchatnewfirebase;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.support.v7.app.AppcompatActivity;
import androidx.appcompat.app.AppCompatActivity;


public class MainChatActivity extends AppCompatActivity {

// TODO: Add member variables here:
private String mDisplayName;
private ListView mChatListView;
private EditText mInputText;
private ImageButton mSendButton;

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

// TODO: Set up the display name and get the Firebase reference


// Link the Views in the layout to the Java code
mInputText = (EditText) findViewById(R.id.messageInput);
mSendButton = (ImageButton) findViewById(R.id.sendButton);
mChatListView = (ListView) findViewById(R.id.chat_list_view);

// TODO: Send the message when the "enter" button is pressed


// TODO: Add an OnClickListener to the sendButton to send a message

}

// TODO: Retrieve the display name from the Shared Preferences


private void sendMessage() {

// TODO: Grab the text the user typed in and push the message to Firebase

}

// TODO: Override the onStart() lifecycle method. Setup the adapter here.


@Override
public void onStop() {
super.onStop();

// TODO: Remove the Firebase event listener on the adapter.

}

}
这是我的app的build.gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

最佳答案

只需要一个import语句。请替换以下import语句

import android.support.v7.app.AppCompatActivity;
下面的 import语句。
import androidx.appcompat.app.AppCompatActivity;

关于java - 无法解析Android Studio中的Symbol v7和appComapat Activity导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62654227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com