You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从StationFragment启动Dashan1Activity遇ActivityNotFoundException求助

Fixing ActivityNotFoundException for Dashan1Activity

Hey there, let’s get this sorted out quick. The error you’re hitting is super straightforward—it just means your app can’t find Dashan1Activity because it’s not properly registered in your AndroidManifest.xml file. Android requires every Activity to be declared here so the system knows how to launch it.

What’s Missing

Your current manifest doesn’t have an entry for miaoli.dashan.Dashan1Activity. Let’s fix that right away.

Step-by-Step Solution

  1. Open your AndroidManifest.xml file.
  2. Inside the <application> tag, add an <activity> entry for Dashan1Activity. Make sure the android:name points to the correct full class path of your activity.

Here’s how your updated manifest should look (assuming your activity lives in the miaoli.dashan subpackage under your main com.coastline20 package):

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

    <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/Theme.Coastline20">
        
        <!-- Your existing activities go here -->
        <activity android:name=".MainActivity" />
        
        <!-- Add this entry for Dashan1Activity -->
        <activity android:name=".miaoli.dashan.Dashan1Activity" />
        
    </application>
</manifest>

Double-Check the Class Path

Make sure the android:name matches your actual package structure:

  • If Dashan1Activity is directly in the com.coastline20 package, use android:name=".Dashan1Activity"
  • If it’s in a deeper subpackage, you can either use the shorthand (like .miaoli.dashan.Dashan1Activity) or the full qualified name (com.coastline20.miaoli.dashan.Dashan1Activity)

Quick Check on Your Jump Code

Also, confirm your intent in StationFragment is targeting the right activity. For Java:

Intent intent = new Intent(getActivity(), Dashan1Activity.class);
startActivity(intent);

For Kotlin:

val intent = Intent(requireActivity(), Dashan1Activity::class.java)
startActivity(intent)

Once you add the activity entry to the manifest, Android will recognize Dashan1Activity and your jump should work as expected!

内容的提问来源于stack exchange,提问作者SpicyBoyd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:03:31