Firebase Messaging Service is Causing Crash in My App. When i Implement FirebaseMessagingService and try to add it on Manifest its showing me "MyFirebaseMessagingServiceservice is not assignable to android.app.service" . When I didn't use the MyFirebaseMessagingServiceservice , then also im getting the error. This question is asked before, I have tried all the answer given in that question but noting workout. Please help.
Im using firebase-messaging:17.1.0
This is the error-
java.lang.IllegalAccessError: com.example.genesishospital.MyFirebaseMessagingService
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3838)
at android.app.ActivityThread.-wrap8(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1909)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
After adding this permission my app works fine.
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Related
Below is the simplified version of the xml file for my settings screen.
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--hardcoded app:fragment crashes in release because of ClassNameNotFound -->
<Preference
app:allowDividerAbove="true"
app:fragment="com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences"
app:icon="#drawable/ic_delete_settings_24dp"
app:title="Clear data" />
</androidx.preference.PreferenceScreen>
It works well in debug version. But when I click on the preference on release apk, it crashes because of ClassNotFoundException.
Stacktrace here
Process: com.flamyoad.tsukiviewer, PID: 13647
androidx.fragment.app.Fragment$c: Unable to instantiate fragment com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences: make sure class name exists
at i.l.d.n.d()
at androidx.fragment.app.Fragment.a()
at i.l.d.r$c.a(:2)
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2)
at i.s.f.b(:29)
at androidx.preference.Preference.a(:23)
at androidx.preference.Preference$a.onClick()
at android.view.View.performClick(View.java:4757)
at android.view.View$PerformClick.run(View.java:19769)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at i.l.d.n.c(:2)
at i.l.d.n.d()
at androidx.fragment.app.Fragment.a()
at i.l.d.r$c.a(:2)
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2)
at i.s.f.b(:29)
at androidx.preference.Preference.a(:23)
at androidx.preference.Preference$a.onClick()
at android.view.View.performClick(View.java:4757)
at android.view.View$PerformClick.run(View.java:19769)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences" on path: DexPathList[[zip file "/data/app/com.flamyoad.tsukiviewer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at i.l.d.n.c(:2)
at i.l.d.n.d()
at androidx.fragment.app.Fragment.a()
at i.l.d.r$c.a(:2)
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2)
at i.s.f.b(:29)
at androidx.preference.Preference.a(:23)
at androidx.preference.Preference$a.onClick()
at android.view.View.performClick(View.java:4757)
at android.view.View$PerformClick.run(View.java:19769)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5289)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 21 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
To me, it looks like the cause is the apk being minified and class name is replaced with shorter string. What can I do in this situation? Is it best practice to replace the app:fragment with function calls in Activity? Or is there any other methods?
I'm using PreferenceFragmentCompat for my application.
The aapt2 generated proguard rules for preferences specifically look for the android:fragment attribute, not app:fragment. You'd want to use android:fragment to automatically keep preference fragments.
I added these lines into my proguard-rules.pro and it stopped crashing.
-keep public class * extends androidx.preference.Preference
-keep public class * extends androidx.preference.PreferenceFragmentCompat
I'm programming a new app and I was trying with different versions. When I try in Nougat, my app doesn't open. It just says:
app has stopped. Open app again?
If I press open again, the app keeps stopping.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "2.0"
multiDexEnabled true
}
}
I tried with buildToolsVersion "25.0.1" and nope. Any help?
Here is my logcat trace when I try to open it in a Nougat device
05-10 09:49:35.119 4709-4709/app E/app: /storage/emulated/0/app/Registros/grupo-registros.csv (No such file or directory)
java.io.FileNotFoundException: /storage/emulated/0/app/Registros/grupo(demo)-registros.csv (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:140)
at app.MainActivity.onCreate(MainActivity.java:175)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
05-10 09:49:35.148 4709-4709/app D/AndroidRuntime: Shutting down VM
05-10 09:49:35.148 4709-4709/app E/AndroidRuntime: FATAL EXCEPTION: main
Process: app, PID: 4709
java.lang.RuntimeException: Unable to start activity ComponentInfo{es/app.MainActivity}: java.util.EmptyStackException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.util.EmptyStackException
at app.MainActivity.copyFileOrDir(MainActivity.java:434)
at app.MainActivity.addSubjectDemo(MainActivity.java:341)
at app.MainActivity.onCreate(MainActivity.java:231)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
EDIT: my manifest´s permission request
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
java.io.FileNotFoundException:/storage/emulated/0/app/Registros/grupo(demo)-registros.csv (No such file or directory)
That happens probably because in Nougat-Android 7.0 there are changes to permissions that may affect your app. It is not enforced, but it pops exception which you probably don't handle. You should read the documentation:
https://developer.android.com/about/versions/nougat/android-7.0-changes.html
And check this answers
Android 7.1 Write to text file
I have the following exception when launching my ap on API 22 and below (works very well on API 24, the target and compile API).
10-06 10:08:57.919 5014-5014/? E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/ads/conversiontracking/AdWordsConversionReporter;
at com.myapp.androidapp.ui.splash.SplashActivity.onResume(SplashActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
at android.app.Activity.performResume(Activity.java:6019)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.conversiontracking.AdWordsConversionReporter" on path: DexPathList[[zip file "/data/app/com.myapp.androidapp.preprod.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.androidapp.preprod.debug-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.myapp.androidapp.ui.splash.SplashActivity.onResume(SplashActivity.java:57)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
at android.app.Activity.performResume(Activity.java:6019)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: com.google.ads.conversiontracking.AdWordsConversionReporter
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
It moves on another class if I comment the line where I use AdWordsConversionReporter (it can be library class or custom class).
Seems to be related with Multidexing but I'm pretty sure I'm using it well.
In my gradle I have this following lines :
multiDexEnabled true
and
compile('com.android.support:multidex:1.0.1') {
exclude group: 'com.android.support'
}
Here is a part of my application class:
public class MyApplication extends MultiDexApplication {
..
}
And a part of my manifest :
<application
android:name=".ui.MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:replace="android:theme">
I tried a lot of solution found here on a lot of questions looking similar like adding MultiDex.install(this) on my Application class, clean my project, re-sync Gradle, enable minify on my gradle (and a lot more) but nothing works.
Any solution to resolve it ?
Works by adding
preDexLibraries false
to my gradle.
I have found several posts regarding classNotFound for MainActivity but all seem to be related to differences in libraries between the main app and support libraries, stuff like that. I have a situation where I am simply creating a new application in Android Studio and with zero modifications, running the helo world default app, fails with this error.
07-20 23:25:46.012 7152-7152/com.rythmair.lvlvalidation D/AndroidRuntime: Shutting down VM
07-20 23:25:46.012 7152-7152/com.rythmair.lvlvalidation E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rythmair.lvlvalidation, PID: 7152
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.rythmair.lvlvalidation/com.rythmair.lvlvalidation.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.rythmair.lvlvalidation.MainActivity" on path: DexPathList[[zip file "/data/app/com.rythmair.lvlvalidation-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2968)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3233)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6873)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rythmair.lvlvalidation.MainActivity" on path: DexPathList[[zip file "/data/app/com.rythmair.lvlvalidation-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2958)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3233)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6873)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Suppressed: java.lang.ClassNotFoundException: com.rythmair.lvlvalidation.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
07-20 23:26:13.377 7152-7152/com.rythmair.lvlvalidation I/Process: Sending signal. PID: 7152 SIG: 9
Not sure what I am missing here.
Try putting this in your manifest if it is not there
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This was an odd one, given the error. The issue turned out to be access rights on the device I was testing (I think). I caught in one part of the stack that it couldn't write code to data/data/... Upon digging in a bit further, I found that I was signed in on my tablet as a test user that I use to validate licensing functionality. While logged in as this user, it would fail any time I tried to build the app with the error shown above. Once I signed back in on my tablet as myself, this issue no longer occurs.
I am trying to use the AltBeacon library with the ranging feature in a remote service. However, I could not manage to get the beacon detection running successfully by now. When declaring the same service as local service everything works fine.
When the service runs in its own process the function startRangingBeaconsInRegion() seems to throw the following exception:
09-17 17:09:14.643 10709-10729/com.my.project E/Parcel﹕ Class not found when unmarshalling: org.altbeacon.beacon.service.StartRMData
java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
at android.os.Parcel.readParcelable(Parcel.java:2245)
at android.os.Message.readFromParcel(Message.java:571)
at android.os.Message.access$000(Message.java:32)
at android.os.Message$1.createFromParcel(Message.java:527)
at android.os.Message$1.createFromParcel(Message.java:524)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:446)
Caused by: java.lang.ClassNotFoundException: org.altbeacon.beacon.service.StartRMData
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
at android.os.Parcel.readParcelable(Parcel.java:2245)
at android.os.Message.readFromParcel(Message.java:571)
at android.os.Message.access$000(Message.java:32)
at android.os.Message$1.createFromParcel(Message.java:527)
at android.os.Message$1.createFromParcel(Message.java:524)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:446)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
09-17 17:09:14.643 10709-10729/com.my.project W/Binder﹕ Caught a RuntimeException from the binder stub implementation.
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: org.altbeacon.beacon.service.StartRMData
at android.os.Parcel.readParcelableCreator(Parcel.java:2295)
at android.os.Parcel.readParcelable(Parcel.java:2245)
at android.os.Message.readFromParcel(Message.java:571)
at android.os.Message.access$000(Message.java:32)
at android.os.Message$1.createFromParcel(Message.java:527)
at android.os.Message$1.createFromParcel(Message.java:524)
at android.os.IMessenger$Stub.onTransact(IMessenger.java:51)
at android.os.Binder.execTransact(Binder.java:446)
Is there any solution for this problem?
The Android Beacon Library is not designed to be run in its own process, so what you describe is not possible. You can see a more detailed discussion of why this is true in this issue discussion here: https://github.com/AltBeacon/android-beacon-library/issues/291
This is an old discussion, but as I found it now, I will post my solution. If you always want your Beacon Service to run in its own process, and therefore you need the altBeacon service to run in same process, it is very doable. Just have your service create the BeaconManager and add the following to your Manifest:
<!-- This is our own BeaconService. We run it in own process, as we don't want it affecting UI, and better crash control.
This also solves the ACRA issue. -->
<service android:name=".BeaconControllerService"
android:process=":my.BeaconControllerService"
android:exported="false"
android:enabled="true">
</service>
<!-- Override beacon library. Set it to our process -->
<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver"
android:process=":my.BeaconControllerService"
tools:replace="process" />
<service
android:name="org.altbeacon.beacon.service.BeaconService"
android:process=":my.BeaconControllerService"
tools:replace="process" />
<service
android:name="org.altbeacon.beacon.BeaconIntentProcessor"
android:process=":my.BeaconControllerService"
tools:replace="process" />
So far it is working for me. This should also solves the ACRA issue. Just remember, as its running in own process, if you want to bind from your application to your Service, you will have to use the Message class or an AIDL binder. See Android docs for info. Also, the BeaconManager has to be in your Service class, not your application.