Dementhius Dementhius - 15 days ago 10
Android Question

Android launch Genymotion but not in device

I´m having a trouble when I want to launch my app in a device with AndroidStudio (AS). If I launch it in Genymotion it works fine, but when I launch in my device, AS installs it but app doesn´t launch.

My AndroidManifest.xml

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

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

<!-- Login Activity -->
<activity
android:name=".LoginActivity"
android:label="Login Account" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity
android:name=".CenterTvSelection"
android:label="@string/title_activity_center_tv_selection" >
</activity>
</application>

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

</manifest>


My gradle.

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.twentyfit.twentyfitpublicidadtv"
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.2.08'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.android.support:support-v4:20.+'
}


LOG:

Launching application: com.twentyfit.twentyfitpublicidadtv/com.twentyfit.twentyfitpublicidadtv.activities.LoginActivity.
DEVICE SHELL COMMAND: am start -n "com.twentyfit.twentyfitpublicidadtv/com.twentyfit.twentyfitpublicidadtv.activities.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.twentyfit.twentyfitpublicidadtv/.activities.LoginActivity }
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.twentyfit.twentyfitpublicidadtv/.activities.LoginActivity } from null (pid=11358, uid=2000) not exported from uid 10048
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1783)
at com.android.commands.am.Am.runStart(Am.java:463)
at com.android.commands.am.Am.run(Am.java:108)
at com.android.commands.am.Am.main(Am.java:81)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:268)
at dalvik.system.NativeStart.main(Native Method)


Could you help me? Thx

Answer

Check your manifest file, the first <activity> tag does not close correctly. The intent-filter should be inside the activity tag, in your case it is not.

More precisely like this:

<activity
        android:name=".LoginActivity"
        android:label="Login Account">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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