Android Studio - App not installed onto phone, but runs

纵饮孤独 提交于 2019-12-10 16:23:01

问题


I use Android Studio to run my app on my phone and it runs fine. But the application itself is never installed... There is no icon for it in the menu. I have to "run" any time I want to test my app. I am presented with no errors.

I believe there is an issue with my manifest. What am I doing wrong here?:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="jb854.eda.kent.ac.uk.edanews">

    <uses-feature
        android:name="android.software.leanback"
        android:required="false" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:name=".EDANewsApplication"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".activity.MainActivity"
            android:windowSoftInputMode="adjustResize">
            <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.eda.kent.ac.uk" android:pathPrefix="/school/"/>
            </intent-filter>

        </activity>
        <activity
            android:name=".activity.CommentsActivity"
            android:theme="@style/AppTheme.TransparentActivity" />
        <activity
            android:name=".activity.ArticleActivity"
            android:theme="@style/AppTheme.TransparentActivity" />
        <activity
            android:name=".activity.FullscreenImageActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/title_activity_fullscreen_image"
            android:theme="@style/AppTheme.TransparentActivity" />
        <activity
            android:name=".activity.FavouritesActivity"
            android:label="@string/title_activity_favourites"
            android:theme="@style/AppTheme.TransparentActivity" />

    </application>
</manifest>

回答1:


You should add category LAUNCHER and action MAIN to your MainActivity:

<activity
    android:name=".activity.MainActivity"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.LAUNCHER"/>

        <data android:scheme="http" android:host="www.eda.kent.ac.uk" android:pathPrefix="/school/"/>
    </intent-filter>

</activity>



回答2:


I was having that same problem because android studio didn't put this dependence in build.gradle file:

compile 'com.android.support:support-v4:23.3.0'



回答3:


Don't use the direct debug-apk file for installing manually. If you want to install manually by copying APK file in storage then

  1. Delete auto-generated APK file located in /app/build/outputs/apk/debug/app-debug.apk

    1. Click on Menu > Build > Build APK(s). This generates debug APK for you.

I am using Android Studios 3.0 Beta 7. This is works for me.



来源:https://stackoverflow.com/questions/30015410/android-studio-app-not-installed-onto-phone-but-runs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!