2

I'm working on an app with 5 or so activities and I tried to change my launcher activity from MapsActivity to MainActivity. I always had the MapsActivity, but today I added the MainActivity and simply swapped the android:name attributes of MapsActiviy and MainActivity. All of a sudden my app wouldn't open. If I tried to run the app, I would see the icon appear on a Nexus 6P and HTC One M7, but after tapping on the icon, nothing happened. All I did was change the manifest FROM:

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

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

    ............
    Skips Several Lines
    ............

    <activity
        android:name=".ChatActivity"
        android:screenOrientation="portrait" />
    <activity android:name=".MainActivity"/>
    <activity android:name=".TotalsListViewActivity" />
    <activity android:name=".PlacesListViewActivity" />
</application>

TO:

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

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

   ............
    Skips Several Lines
    ............

    <activity
        android:name=".ChatActivity"
        android:screenOrientation="portrait" />
    <activity android:name=".MapsActivity"/>
    <activity android:name=".TotalsListViewActivity" />
    <activity android:name=".PlacesListViewActivity" />
</application>

I read several posts such as https://stackoverflow.com/a/3632061/4937741 about how changing the manifest may not be enough for Android Studio to change its run configuration for the app. All the posts seem to say is to go to Run > Edit Configurations and make sure the new default launcher activity is set to run rather than your old launcher activity. In my case it is always set to run the default activity:

Editing Configurations

I've tried changing it to explicitly run MainActivity, but that didn't help. I even tried deleting MapsActivity, but that didn't help. The LogCat did not seem to show any errors:

   10-19 00:48:04.383 20349-20407/? D/ClClient: Not sending keepalive.  Current connection state=STOPPED

                                             --------- beginning of system
10-19 00:48:05.075 914-3870/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.artfara.apps.kipper/.MainActivity (has extras)} from uid 10029 on display 0
10-19 00:48:05.077 513-2908/? D/audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
10-19 00:48:05.091 513-2908/? D/audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
10-19 00:48:05.091 513-2908/? D/msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
10-19 00:48:05.092 513-2908/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 1
10-19 00:48:05.105 513-2908/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
10-19 00:48:05.109 513-2908/? D/audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback speaker
10-19 00:48:05.132 1350-1350/? I/GrantPermissionsActivity: No package: null
                                                           android.content.pm.PackageManager$NameNotFoundException
                                                               at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:137)
                                                               at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.getCallingPackageInfo(GrantPermissionsActivity.java:335)
                                                               at com.android.packageinstaller.permission.ui.GrantPermissionsActivity.onCreate(GrantPermissionsActivity.java:100)
                                                               at android.app.Activity.performCreate(Activity.java:6251)
                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                               at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:148)
                                                               at android.app.ActivityThread.main(ActivityThread.java:5422)
                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-19 00:48:05.141 914-3581/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2335ed6 attribute=null, token = android.os.BinderProxy@182e308
10-19 00:48:05.637 513-2908/? D/audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback speaker
10-19 00:48:05.639 513-2908/? D/audio_hw_primary: disable_snd_device: snd_device(2: speaker)
10-19 00:48:05.654 513-2908/? I/soundtrigger: audio_extn_sound_trigger_update_device_status: device 0x2 of type 0 for Event 0
10-19 00:48:05.932 914-3870/? D/WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@4c604e5}
10-19 00:48:05.986 914-3912/? D/WifiService: releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@4c604e5}
10-19 00:48:06.011 3315-3315/? I/wpa_supplicant: wlan0: WPA: Group rekeying completed with f0:b2:e5:bd:99:c0 [GTK=CCMP]
10-19 00:48:06.012 914-3106/? D/IpReachabilityMonitor: probing ip=10.31.112.1%5
10-19 00:48:06.038 19446-19453/? E/DataBuffer: Internal data leak within a DataBuffer object detected!  Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@7858ede)
10-19 00:48:07.091 914-3121/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 168]
10-19 00:48:07.105 914-3121/? D/ConnectivityService: updateNetworkScore for NetworkAgentInfo [WIFI () - 168] to 56
10-19 00:48:08.712 668-701/? I/Finsky: [1983] com.google.android.finsky.c.e.run(2152): Replicating app states via AMAS.
10-19 00:48:08.744 914-3261/? I/sensors: batch
10-19 00:48:08.744 914-3261/? I/sensors: activate
10-19 00:48:08.742 4376-4376/? W/Binder_C: type=1400 audit(0.0:141173): avc: denied { ioctl } for path="socket:[1339276]" dev="sockfs" ino=1339276 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
10-19 00:48:08.742 4376-4376/? W/Binder_C: type=1400 audit(0.0:141174): avc: denied { ioctl } for path="socket:[1339276]" dev="sockfs" ino=1339276 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
10-19 00:48:08.753 914-3039/? I/hubconnection: sensorhub said: 'batch 4 flags:0, sampling_rate_Hz:10.00, max_report_latency_us:0'
10-19 00:48:08.753 914-3039/? I/hubconnection: sensorhub said: 'activate 4 enable:1'
10-19 00:48:08.876 668-701/? I/Finsky: [1983] com.google.android.finsky.c.c.a(314): Completed 0 account content syncs with 0 successful.
10-19 00:48:08.878 668-668/? I/Finsky: [1] com.google.android.finsky.services.j.a(148): Installation state replication succeeded.
10-19 00:48:08.896 19619-19625/? W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/metrics.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
10-19 00:48:08.897 19619-19625/? W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/help_responses.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
10-19 00:48:08.897 19619-19625/? W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
10-19 00:48:09.061 914-3581/? I/sensors: activate
10-19 00:48:09.064 914-3039/? I/hubconnection: sensorhub said: 'activate 4 enable:0'
10-19 00:48:09.426 14682-14682/? I/ServiceManager: Waiting for service AtCmdFwd...
10-19 00:48:10.427 14682-14682/? I/ServiceManager: Waiting for service AtCmdFwd...
10-19 00:48:11.429 14682-14682/? I/ServiceManager: Waiting for service AtCmdFwd...
10-19 00:48:12.430 14682-14682/? I/ServiceManager: Waiting for service AtCmdFwd...
10-19 00:48:13.432 14682-14682/? I/ServiceManager: Waiting for service AtCmdFwd...
10-19 00:48:14.383 20349-20407/? D/ClClient: Not sending keepalive.  Current connection state=STOPPED
10-19 00:48:14.433 14682-14682/? W/Atfwd_Sendcmd: AtCmdFwd service not published, waiting... retryCnt : 3
10-19 00:48:17.418 24712-14857/? D/com.gsamlabs.bbm.lib.NotifyingService: ===:56:3930:28.5:2
10-19 00:48:21.824 914-7312/? D/NetlinkSocketObserver: NeighborEvent{elapsedMs=82913527, 10.31.112.1, [0026980A93C1], RTM_NEWNEIGH, NUD_STALE}
10-19 00:48:24.383 20349-20407/? D/ClClient: Not sending keepalive.  Current connection state=STOPPED

I'll also throw in MainActivity.java and activity_main.xml:

MainActivity.java

import android.*;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d("MainActivity","onCreate");
    } 
}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.artfara.apps.kipper.MainActivity">

    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_marginStart="108dp"
        android:layout_marginTop="117dp"
        android:id="@+id/textView" />
</RelativeLayout>

Thanks in advance for any assistance!

Community
  • 1
  • 1
College Student
  • 1,719
  • 16
  • 15
  • Have you tried cleaning and rebuilding the project? You might also want to uninstall the app once and install it again. – 2hamed Oct 19 '16 at 05:09
  • Thanks @HamedMomeni but I have tried uninstalling the app and if you mean Build > Clean Project and then Build > Rebuild Project, I have done that too. – College Student Oct 19 '16 at 05:16
  • Was this ever resolved, I have the exact same issue and tried all these suggestions. – edgar_wideman Mar 20 '21 at 19:27
  • Unfortunately I tried the suggestions and they didn't work for me. I ended up giving up and just keeping the old name for my app's launching activity – College Student Mar 24 '21 at 19:18

2 Answers2

0

Maybe you need to explicitly set your default activity.

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

Try put this in the MapsActivity intent filter.

<activity android:name=".MapsActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
Eoin
  • 4,050
  • 2
  • 33
  • 43
0

This exception is thrown when a given package, application, or component name cannot be found, So please check:

1) Whether your package name is correct.

2) The activity you mentioned as LAUNCHER ACTIVITY does exist in the defined package

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="check_here">
Muhammad Farhan Habib
  • 1,859
  • 20
  • 23
  • as far as I know my package is correct. The package in my manifest is the same as listed in all my files, including in MainActivity, the activity I'm trying to make launcher activity. Thanks anyways. – College Student Oct 21 '16 at 01:46
  • Ok then I think this issue must resolve after deleting MainActivity & then re-create from Menu and set it as Launcher Activity – Muhammad Farhan Habib Oct 21 '16 at 05:34