android - 通过 android studio 安装的应用程序未显示在启动器中

标签 android android-studio android-gradle-plugin

我正在开发的应用程序突然没有显示在启动器中。我可以在“设置”>“应用程序”中看到它,当我从 Android Studio 启动它时,它像普通应用程序一样运行。

所以听起来我好像失踪了:

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

在 list 中。不,他们在那里。还有什么可能导致这种情况?构建 gradle 是否可能与此混淆?

这是我的完整 list 和构建 gradle 文件。谁能看到我遗漏的东西?

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

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

<uses-feature android:name="android.hardware.camera" />

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

    <meta-data
        android:name="com.crashlytics.ApiKey"
        android:value="xxxxxx" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="xxxx" />

    <activity
        android:name="com.example.app.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />

            <data android:host="com.example.twitter.oauth" android:scheme="oauth" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.example.app.SigninActivity"
        android:label="@string/sign_in"
        android:screenOrientation="portrait" >
    </activity>

    <activity
        android:name="com.example.app.PostActivity"
        android:label="@string/action_new"
        android:screenOrientation="portrait" >
    </activity>

    <activity
        android:name="com.example.app.twitter.OAuthActivity"
        android:label="@string/action_new"
        android:screenOrientation="portrait" >
    </activity>

    <activity
        android:name="com.facebook.LoginActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:label="@string/app_name" />

    <receiver
        android:name="com.example.app.gcm.GCMBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.example.gcm" />
        </intent-filter>
    </receiver>

    <service android:name="com.example.app.gcm.GCMIntentService" />

</application>

</manifest>

build.gradle:

buildscript {
    repositories {
        maven { url 'http://download.crashlytics.com/maven' }
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

repositories {
    maven { url 'http://download.crashlytics.com/maven' }
}


android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    def versionPropsFile = file('version.properties')
    if (versionPropsFile.canRead()) {
        def Properties versionProps = new Properties()

        versionProps.load(new FileInputStream(versionPropsFile))

        def value = 0

        def runTasks = gradle.startParameter.taskNames
        if ('assemble' in runTasks || 'assembleRelease' in runTasks || 'aR' in runTasks) {
            value = 1;
        }

        def versionMajor = 1
        def versionMinor = 0
        def versionPatch = versionProps['VERSION_PATCH'].toInteger() + value
        def versionBuild = versionProps['VERSION_BUILD'].toInteger() + 1
        def version_Code = versionProps['VERSION_CODE'].toInteger() + value

        versionProps['VERSION_PATCH'] = versionPatch.toString()
        versionProps['VERSION_BUILD'] = versionBuild.toString()
        versionProps['VERSION_CODE'] = version_Code.toString()

        versionProps.store(versionPropsFile.newWriter(), null)

        defaultConfig {
            versionCode version_Code
            versionName "${versionMajor}.${versionMinor}.${versionPatch} (${versionBuild}) Alpha"
            minSdkVersion 15
            targetSdkVersion 19
        }
    } else {
        throw new GradleException("Could not read version.properties!")
    }

    signingConfigs {
        debug {
            storeFile file('xxx.jks')
            storePassword 'xxx'
            keyAlias 'debug'
            keyPassword 'xxx'
        }
        releaseKey {
            storeFile file('xxx.jks')
            storePassword 'xxx'
            keyAlias 'com.example.app'
            keyPassword 'xxx'
        }
    }

    buildTypes {
        debug {
            debuggable true
            applicationIdSuffix '.debug'
            runProguard false
        }
        release {
            runProguard false
        }
    }

    lintOptions{
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    compile files('libs/twitter4j-core-4.0.1.jar')
    compile files('libs/okhttp-2.0.0.jar')
    compile files('libs/okio-1.0.0.jar')
    compile 'com.android.support:support-v4:20.0.+'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:20.0.+'
    compile project(':facebook')
    compile project(':parallaxViewPager')
    compile 'com.crashlytics.android:crashlytics:1.+'
}

最佳答案

您实际上可以在启动器 Activity 中使用 data android:host 进行 Intent 过滤器。它只需要是包含启动器类别的过滤器的单独过滤器。以下设置使我的 Activity 既是启动器又是可浏览的,以便读取输入参数:

<activity android:name=".MainActivity" android:label="@string/app_name_full">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="http"
                  android:host="www.giorgos.nl"
                  android:pathPrefix="/cv" />
            <data android:scheme="cv"
                  android:host="giorgos"/>
        </intent-filter>
</activity>

关于android - 通过 android studio 安装的应用程序未显示在启动器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24547209/

相关文章:

Android Studio 如何从多个库项目中打包单个 AAR?

android - 创建一个具有多个aar文件作为依赖项的aar

android - 将android studio更新为chipmunk后导航组件方向生成类中的构建时间错误

android - 有没有办法将 Android 应用程序绑定(bind)到长按主页按钮?

android - 如何注销所有应用程序

java - 如何以编程方式在不同设备上添加相同大小的图标?

android - 使用android Studio在gson反序列化中出错

android - 从左侧添加文本

java - 需要用Android Studio删除缓存

android - 模拟器 SD 卡出现为 "removed"