Flutter apps displaying grey screen on apps start launch - flutter

I don't know if this is normal or a bug issue, I've noticed some apps (my own included)
after making a release version or even a debug one when launch it will display a weird bronze background color few milliseconds Screenshot below) is this normal on build or is there any resolution for this ?
Or perhaps could this be related to AndroidManifest
Edit : I'll post my build gradle and AndroidManifest in case it helps
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.release
}
AndroidManifest :
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-permission android:name="android. permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="myapp"
android:icon="#mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
>
<receiver android:name="com.app.myapp">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<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="https"
android:host="YOUR_SUBDOMAIN.page.link" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
<meta-data android:name="com.google.android.geo.API_KEY"
android:value=""/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value=""/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<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="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<service android:name="com.app.fayda.localnotifications.services.LocalNotificationsService"
android:exported="false" />
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
Here is another example of Tinder app which has the same issue right before Splash screen appear

After few investigation I'll give some potential solution :
To check the logcat issue I had to change to release version build variant
(1). Flutter clean and flutter pub get
(2). Open Android Module of Project in another window
(3). Wait for all process and after that First Clean Project and Rebuild Project
(4). Wait for Rebuild process complete and now change your build variants first at your left bottom you can see tab "Build variant" open it and after that in the front of "app" folder you can see in column of "Active Build Variant" like such "debug" please change it to "release"
(5). after that repeat step 3
(6) and run project from Android Module If you face the grey screen issue then you can know what is the exactly error in Logcat section and also make sure that your keystore file and keystore details are proper for release
This is another potential solution apparently this file launch_background.xml causing this every time you start the app it will launch this first and there's no way to bypass this as far as I know you may able to change the color as you see fit or put image but there's no workaround around this unfortunately

Related

What's wrong with this code.When I clean the flutter dependencies and run flutter pub get then I got this error. What I have to do to fixed this error

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bpls">
<uses-permission android:name="android.permission.INTERNET"/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:label="bpls"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Error parsing LocalFile: 'C:\Users\prashant\Desktop\bpls\android\app\src\main\AndroidManifest.xml' Please ensure that the android manifest is a valid XML document and try again.
You Just Need to Replace this with your AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bpls">
<uses-permission android:name="android.permission.INTERNET"/>
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:label="bpls"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` i have already set it to true and false

Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined.
In Maniefest File
i Have already set it to
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nearxt">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<application
android:label="NearXT"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyA_unpQsav6JlIszXYqGH9E19CMMe_Wo0w"/>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<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="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</manifest>

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter,

Hi can anyone help me I just follow the instruction here: developer.android.com/about/versions/12/behavior-changes-12#exported
but still I am getting the same error " You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported"
when uploading the file to google play consule App bundles release
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.HatidRider.app"
xmlns:tools="http://schemas.android.com/tools">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application
android:name=".App"
tools:replace="android:label"
android:label="Hatid-PH Delivery"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<service
android:name="com.HatidRider.app.BackgroundService"
android:enabled="true"
android:exported="true" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.HatidRider.app"
xmlns:tools="http://schemas.android.com/tools">
<!-- io.flutter.app.FlutterApplication is an
android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate
method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application
android:name=".App"
tools:replace="android:label"
android:label="Hatid-PH Delivery"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"/>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<service
android:name="com.HatidRider.app.BackgroundService"
android:enabled="true"
android:exported="true" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
Check if it works now, I have explicity set android:exported = "true"
as you have launcher and in other places

Android Studio : Client not ready yet... Timed out waiting for process to appear on device

Trying to run my app but it keeps showing the following error. I have tried every available solution on stackoverflow.com but the problem still remain.
I have attached manifest file for reference. Android Studio3.2.1 target SDK-28
12/27 01:36:23: Launching app
$ adb push F:\Android_projects\CaliberGaming\CaliberGaming\app\build\outputs\apk\debug\app-debug.apk /data/local/tmp/com.caliber.mskhan.calibergaming
$ adb shell pm install -t -r "/data/local/tmp/com.caliber.mskhan.calibergaming"
Success
APK installed in 3 s 482 ms
Client not ready yet..
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.caliber.mskhan.calibergaming">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:name=".helper.MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:fullBackupContent="#xml/backup_descriptor"
tools:ignore="GoogleAppIndexingWarning">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<uses-library android:name="org.apache.http.legacy"
android:required="false" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.razorpay.ApiKey"
android:value="rzp_test_PpOinqLyVBHOcP" />
<activity
android:name=".SplashScreen"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegistrationActivity" />
<activity android:name=".Login" />
<activity
android:name=".HomeActivity"
android:label="#string/title_activity_home"
android:theme="#style/AppTheme.NoActionBar" />
<activity
android:name=".ProfilePage"
android:parentActivityName=".HomeActivity"
android:windowSoftInputMode="stateAlwaysHidden"/>
<activity
android:name=".CenterActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" />
<activity
android:name=".GamersProfile"
android:parentActivityName=".HomeActivity"
tools:ignore="UnusedAttribute" />
<activity
android:name=".CenterRequestActivity"
android:label="#string/title_activity_center_request" />
<activity
android:name=".FollowList"
android:label="Following" />
<service
android:name=".TimingService"
android:enabled="true"
android:exported="true" />
<activity
android:name=".EventInfoActivity"
android:label="#string/title_activity_event_info"
android:theme="#style/AppTheme.NoActionBar" />
<activity
android:name=".TeamProfile"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.NoActionBar"
tools:ignore="UnusedAttribute" />
<activity
android:name=".PendingActivity"
android:parentActivityName=".HomeActivity"
tools:ignore="UnusedAttribute" />
<activity
android:name=".EventsActivity"
android:parentActivityName=".HomeActivity"
tools:ignore="UnusedAttribute" />
<activity
android:name=".LeaderBoards"
android:parentActivityName=".HomeActivity"
tools:ignore="UnusedAttribute" />
<activity android:name=".ChangePassword" />
<activity
android:name=".ForgotPassword"
android:parentActivityName=".Login"
tools:ignore="UnusedAttribute" />
<activity
android:name=".MatchesDOTA"
android:parentActivityName=".TeamProfile"
tools:targetApi="jelly_bean" />
<activity
android:name=".MatchesCSGO"
android:parentActivityName=".TeamProfile"
tools:targetApi="jelly_bean" />
<activity
android:name=".VerificationActivity"
android:parentActivityName=".Login"
tools:ignore="UnusedAttribute" />
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" />
<activity android:name=".GettingLocation" />
<activity android:name=".SteamLogin"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".PaymentResult" />
<activity android:name=".products" />
<receiver
android:name=".receiver.ConnectivityReceiver"
android:enabled="true">
<intent-filter>
<action
android:name="android.net.conn.CONNECTIVITY_CHANGE"
tools:ignore="BatteryLife" />
</intent-filter>
</receiver>
<service
android:name=".service.LocationService"
android:enabled="true"
android:exported="true" />
<service
android:name=".service.GPSTracker"
android:enabled="true"
android:exported="true" />
</application>
</manifest>

Starting an Android service from a different package

I can't seem to start my android service when the service code is in another package that is not the same package as the MainActivity of the main app.
I have tried many many ways, even the AIDL method, and I can't get it to work at all.
MainActivity code
ServiceIntent.setComponent(new ComponentName("com.service.luna","com.service.luna.VService" ));
bindService(ServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
MainActivty Manifest
<?xml version="1.0" encoding="utf-8"?>
<!-- <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" /> This is set from Gradle -->
<!-- Needed for camera passthrough -->
<!--<uses-permission android:name="android.permission.CAMERA" />-->
<!-- Needed to write thumbs -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Needed to for volume -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Needed for Google Play Services GPS -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.usb.host" />
<!-- Needed for uploading crash reports -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
<application android:allowBackup="true" android:icon="#drawable/ic_launcher" android:label="#string/app_name"
android:hardwareAccelerated="true" android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
<!-- singleTask launchMode because we never want multiple copies of the app running, -->
<!-- but we might want to internally spawn other activities -->
<!-- Theme.DeviceDefault.NoActionBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition -->
<activity android:name="com.main.luna.MainActivity"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="screenSize|orientation|keyboardHidden|keyboard"
>
<!-- this filter lets the apk show up as a launchable icon -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.service.luna.VService" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.service.luna.VService" android:process=":VServiceRemote" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="com.service.luna.VService"/>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<receiver android:name="com.main.luna.ConnectivityChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>
</application>
Service Code
public class VService extends Service implements Serializable{
....
Service Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.service.luna">
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true">
</application>
When My code finally runs, I receive a
bindService callerProcessName:com.main.luna, calleePkgName: com.service.luna, action: null
Unable to start service Intent { pkg=com.service.luna cmp=com.service.luna/.VService } U=0: not found
The name of the main package is com.main.luna and the service is in package com.service.luna
If someone has solved this before, please let me know.
Try to enable the exported option in your manifest while adding your service ( android:exported="true")
<service android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:icon="drawable resource"
android:isolatedProcess=["true" | "false"]
android:label="string resource"
android:name="string"
android:permission="string"
android:process="string" >
. . .
</service>
and make sure you are using the Correct name of your Package name
Also check this post having similar situation
How do I start a service which is defined in a different package?