2015-11-22 17 views
13

私はアンドロイドを新しくしており、問題が発生しました。 コンソールに「起動アクティビティを特定できませんでした:デフォルトのアクティビティが見つかりません」と表示されました。 私は、マニフェストに起動アクティビティを特定できませんでした:デフォルトのアクティビティが見つかりません

<intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
</intent-filter> 

を追加しました。 そしてキャッシュを無効にして再試行しましたが、まだ動作しません。 アンドロイドスタジオでメインアクティビティを含むクラスファイルが緑色に変わります。私はそれが何を意味するのか分かりません。 これは私のマニフェストファイルです。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.mrrobot.mycoolweather" > 
<uses-permission android:name="android.permission.INTERNET"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" > 
    <Activity  android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity" 
     android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
    </Activity> 
</application> 

</manifest> 

chooseAreaActivityは、ランチャーアクティビティとして使用したいものです。あなたはDEFAULTにカテゴリを変更する必要が他の活動のために

<activity 
    android:name=".MainActivity" 
    android:label="YourAppName" 
    android:theme="@style/AppTheme.NoActionBar" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

:あなたは、カテゴリLAUNCHER(起動アプリの最初のアクティビティ)でこれを追加する必要がマニフェストで主な活動については enter image description here

+0

**フル**マニフェストを投稿できますか? –

+2

フルAndroidManifest.xmlを表示 –

答えて

23

<activity 
    android:name=".OtherActivity" 
    android:theme="@style/AppTheme.NoActionBar" > 
    <intent-filter> 
      <action android:name="package.OtherActivity" /> 

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

これをチェックするActivityとこのStart Another Activity

だからあなたのコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.mrrobot.mycoolweather" > 
<uses-permission android:name="android.permission.INTERNET"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" > 

    <activity 
     android:name=".activity.ChooseAreaActivity" 
     android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

</manifest> 
+0

自分のパッケージをデフォルトパッケージの下に追加します。私はその道について間違いを犯しましたか? –

+0

私はあなたのコードで更新の回答を持っています@ JiaweiYang今すぐ確認してください:D –

+1

私は参照してください...私は "活動"の代わりに "活動"を使用します。今私はちょっと気分が悪いと思うよ。ありがとう! –

5

時にはそれはちょうど私が "デフォルトの活動は見られない" 問題にのカップルを持っていたAndroidのメーカー

Click on "File" and then "Invalidate Cache"


を再起動して解決され、私はアンドロイドスタジオの再起動を解決できました。

+0

ありがとう –

1

IDEAのアップグレード、Android Studioのバージョンのアップグレード、または新しいAPKの生成後にエラーが発生する場合は、IDEのキャッシュを更新する必要があります。

File -> Invalidate Caches/Restart... 
0

私の主な活動はAndroid Manifest Fileで宣言されていません。それがそのエラーになった理由です。このエラーは、Android Manifestファイルの宣言に問題があるために発生します。これをチェックしてください。 :D

関連する問題