首页 > 解决方案 > tool.context 中未解析的类

问题描述

当我创建一个新项目时出现错误

“工具.context =“.MainActivity”中的“解算器类”MainActivity“

如果我单击“运行应用程序”,则显示未找到默认活动

试图这样写:tool.context =“com.example.android.myapplication”,但它仍然报告未找到默认活动。几天前运行良好的项目现在也有这个问题。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

标签: javaandroidandroid-studio

解决方案


你的packageor applicationIdin AndroidManifest.xmland build.gradlefile 和你Activity的包结构一样吗?

那是com.example.android.myapplication


推荐阅读