javaandroidreact-nativemain-activity

intent-filter build two apps instead of one in Android Studio


I have a react native Project that's integrated with onesignal notification, in Android app when I built my app using Android Studio it installs two apps one called onesignal and the other one my main app and app runs perfect

I tried to remove the intent from my activity

       <activity android:name="bkholdnews.beonews.MainActivity" android:label="OneSignal Example" android:launchMode="singleTop" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

and rebuilt the app, it installs one app but when I open it it says app keeps stooping!

my MainActivity code

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hhz20.bkholdnews"
    android:versionCode="29"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <!-- Approximate location - If you want to use promptLocation for letting OneSignal know the user location. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!--  Precise location If you want to use promptLocation for letting OneSignal know the user location. -->

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
        android:name="bkholdnews.beonews.MainApplication"
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:usesCleartextTraffic="true"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:label="@string/app_name"
        android:icon="@drawable/icon"
        android:theme="@style/SplashTheme">

        <activity
            android:launchMode="singleTop"
            android:name="bkholdnews.beonews.SplashActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="bkholdnews.beonews.MainActivity" android:label="OneSignal Example" android:launchMode="singleTop" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    </application>

</manifest>

CRASH LOGCAT

    --------- beginning of crash
2019-06-01 17:31:18.598 30803-30803/com.hhz20.bkholdnews E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.hhz20.bkholdnews, PID: 30803
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hhz20.bkholdnews/bkholdnews.beonews.SplashActivity}: android.content.res.Resources$NotFoundException: Drawable com.hhz20.bkholdnews:drawable/splash_screen with resource ID #0x7f0700b1
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.content.res.Resources$NotFoundException: Drawable com.hhz20.bkholdnews:drawable/splash_screen with resource ID #0x7f0700b1
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable/splash_screen.xml from drawable resource ID #0x7f0700b1
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:847)
        at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:631)
        at android.content.res.Resources.getDrawableForDensity(Resources.java:888)
        at android.content.res.Resources.getDrawable(Resources.java:827)
        at android.content.Context.getDrawable(Context.java:626)
        at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:463)
        at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
        at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
        at android.support.v7.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
        at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
        at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
        at bkholdnews.beonews.SplashActivity.onCreate(SplashActivity.java:9)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <bitmap> requires a valid 'src' attribute
        at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:849)
        at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:770)
        at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
2019-06-01 17:31:18.599 30803-30803/com.hhz20.bkholdnews E/AndroidRuntime:     at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1321)
        at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:279)
        at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:194)
        at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
        at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
        at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:833)
            ... 27 more
2019-06-01 17:31:18.612 30803-30803/com.hhz20.bkholdnews I/Process: Sending signal. PID: 30803 SIG: 9

Solution

  • you might have to remove intent filter from main activity in the manifest file and start activity transaction through splash screen to main activity and also remove launchmode from mainactivity