当前位置: 首页 > 知识库问答 >
问题:

应用程序安装后在Android Studio中启动活动时出错

干宏邈
2023-03-14

我已经在android studio 3.5版本中创建了一个应用程序,其中约束布局中只有一个图像视图。但当我在emulator中运行应用程序时,会显示以下错误:

显示错误:

    11/08 11:27:31: Launching 'app' on 3.7  WVGA (Nexus One) API 22.
$ adb shell am start -n "com.example.trialanderror/com.example.trialanderror.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.example.trialanderror/com.example.trialanderror.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.trialanderror/.MainActivity }

Error while Launching 

XML代码:

<?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">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:src="@drawable/beer" />
</androidx.constraintlayout.widget.ConstraintLayout>

主要活动:

package com.example.trialanderror;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;




public class MainActivity extends AppCompatActivity {

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

    }

  }

Android屏幕截图:

这里是ANDROIDActudio.xml文件:(当我打开它时,显示的消息是:App不是谷歌搜索可索引的;考虑用ActoVIEW意图过滤器发行ID添加至少一个活动:GoGoLePixIdxCurror警告)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.trialanderror">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

共有2个答案

宋飞文
2023-03-14

首先,在主活动中定义Imageview。

ImageViewer imageView = (ImageViewer)findViewById(R.id.imageView);

然后确保您在ImageViewer中使用的图像为.png格式。如果问题仍然存在,请检查您的AndroidManifest文件。

史淳
2023-03-14

请确保您已将此页放在Androidanifest.xml

 类似资料:
  • 我正在开发一个应用程序,它也可以从另一个应用程序启动。姑且称之为“被叫app”和“主叫app”。我正在使用protection level“signature”向“被调用的应用程序”的启动器活动添加权限。但是,当我添加此权限时,我无法从应用程序图标启动“被调用的应用程序”。上面写着“App未安装”。我还尝试使用“危险”保护级别。它给出了同样的错误。 我想这个问题可能是因为我给启动器活动提供了一个自

  • 我正在尝试使用简单的spring启动应用程序。我在ApplicationContext上启动应用程序时遇到问题。 2017-04-26 11:17:31.101警告14528---[main]s.c.a.AnnotationConfigApplicationContext:上下文初始化期间遇到异常-取消刷新尝试:org。springframework。豆。工厂未满足的PendencyExcepti

  • 当我试图从web.xml映射ApplicationContext.xml文件以使用spring ioc时,我的应用程序没有开始在catalina.out中显示以下错误

  • 我有一份Java申请。 应用程序有一个决定应用程序是否在启动时启动的设置。 目前,我通过在StartUp items文件夹中放置/删除快捷方式实现了这一点。 然而,我想知道是否有更好的方法来处理这种行为。 编辑 是的,是视窗。抱歉之前没有清除。 应用程序有一个UI,用户可以在其中触发操作,并且应用程序在运行时定期在后台运行一些任务。 @Peter,如何使用应用程序中的代码更改注册表?这种方法是否与

  • 杀死应用程序并发送推送,它正在重定向到所需的活动后,处理这个推送,把应用程序放在后台并发送推送。它将恢复最后一个活动,但意向性附加为NULL。

  • 当我运行这个错误时,请帮助我解决这个问题 启动应用程序上下文时出错。要显示条件,请报告启用“调试”后重新运行应用程序。2019-02-11 10:53:55.839错误8804 --- [ restartedMain]o. s. b. d.日志失败分析记者: 应用程序启动失败 说明: com中的字段userDao。实例Spring Security应用程序编程接口。服务UserServiceImp