简体   繁体   中英

Android. No Launcher activity found?

When I'm trying running my app:

No Launcher activity found!
The launch will only sync the application package on the device!

I've readed all questions about similar problems, I changed my manifest.xml but every time I get same error. I stucked for an hour trying to solve this and nothing works.

Here's my manifest fragment:

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" >
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!-- External storage for caching. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- My Location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Maps API needs OpenGL ES 2.0. -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="YOUR_OWN_KEY" />
    />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mosbin.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity
            android:name="com.example.mosbin.Run"
            android:label="@string/title_activity_run"
            android:parentActivityName="com.example.mosbin" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.mosbin" />
        </activity>
        <activity
            android:name=".Stats"
            android:label="@string/title_activity_stats"
            android:parentActivityName="com.example.mosbin" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.mosbin" />
        </activity>
    </application>
</uses-sdk>

What's wrong with this code? Before it appears I just wanted to add new activity ...

< /uses-sdk > clear this tag at the end of your manifest and change this

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" > missing / here

to :

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" /> 

Also take these into your application tag :

<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="YOUR_OWN_KEY" />

https://developers.google.com/maps/documentation/android/start .

Check the link and the topic under Adding the API Key to your application

This is what you Manifest should look like:

Do note how the various tags have been opened and closed. And nested where required.

Also, read up on the Android Manifest Docs . That will ensure there is no confusion in the future. ;-)

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" >
    </uses-sdk>

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!-- External storage for caching. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- My Location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Maps API needs OpenGL ES 2.0. -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="YOUR_OWN_KEY" />


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mosbin.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.mosbin.Run"
            android:label="@string/title_activity_run"
            android:parentActivityName="com.example.mosbin" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.mosbin" />
        </activity>
        <activity
            android:name=".Stats"
            android:label="@string/title_activity_stats"
            android:parentActivityName="com.example.mosbin" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.mosbin" />
        </activity>
    </application>

</manifest>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM