My Android App is crashed on android 10 Q mobile but I am unable to reproduce this crash and resolve it.
This is the error message:
Fatal Exception: java.lang.SecurityException: Not allowed to bind to service Intent { act=com.google.android.gms.clearcut.service.START pkg=com.google.android.gms }
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1741)
at android.app.ContextImpl.bindService(ContextImpl.java:1651)
at android.content.ContextWrapper.bindService(ContextWrapper.java:705)
at com.google.android.gms.common.stats.ConnectionTracker.zza(:22)
at com.google.android.gms.common.internal.zzf.zze(:30)
at com.google.android.gms.common.internal.zze.zza(:15)
at com.google.android.gms.common.internal.BaseGmsClient.zza(:103)
at com.google.android.gms.common.internal.BaseGmsClient.connect(:142)
at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.connect(:224)
at com.google.android.gms.common.api.internal.GoogleApiManager.zab(:47)
at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(:173)
at android.os.Handler.dispatchMessage(Handler.java:103)
at com.google.android.gms.internal.base.zap.dispatchMessage(:8)
at android.os.Looper.loop(Looper.java:232)
at android.os.HandlerThread.run(HandlerThread.java:67)
Here are the firebase crash pics:
please register your service in manifest if not ex: <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Related
Hello after upgrade I have user who have crash, I don't understand why.
here is the logs
Problem 1:
Fatal Exception: i.b.a.b.i.b: Complete with: result l.b.m1.a$b#74d2219
at com.google.android.gms.tasks.zzw.zzh(zzw.java:5)
at com.google.android.gms.tasks.zzw.zza(zzw.java:8)
at com.google.android.gms.tasks.zzz.run(zzz.java:27)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0(ThrottledForwardingExecutor.java)
at com.google.firebase.firestore.util.ThrottledForwardingExecutor.lambda$execute$0$ThrottledForwardingExecutor(ThrottledForwardingExecutor.java)
at com.google.firebase.firestore.util.-$$Lambda$ThrottledForwardingExecutor$MfIJbVuxZtLwosAgPzPA-cU66Ko.run(-.java:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Problem 2:
Fatal Exception: java.lang.RuntimeException: Internal error in Cloud Firestore (24.2.0).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3(AsyncQueue.java:19)
at com.google.firebase.firestore.util.-$$Lambda$AsyncQueue$jx84dqgUsF4ojecSMurRqFLFD1Y.run(-.java:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
you have to add internet permissions, copy this code in AndroidManifest.xml :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
With the new privacy changes in effect with Android Q, it is now mandatory for any app using MediaProjection api to specify android:foregroundServiceType attribute in the service tag under manifest.
But recently, I noticed that though I set the android:foregroundServiceType="mediaprojection" there is a security exception thrown. Does anybody have any idea what I'm doing wrong?
Manifest:
<service
android:name=".services.MediaProjectionService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="mediaProjection" />
Exception thrown:
java.lang.RuntimeException: Unable to start service com.package.app.services.MediaProjectionService#6d0fed2 with Intent { act=com.package.app.services.action.startrecording cmp=com.package.app/.services.MediaProjectionService(has extras) }: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4103)
at android.app.ActivityThread.access$1800(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7343)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)
Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
at android.media.projection.MediaProjection.<init>(MediaProjection.java:58)
at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104)
at com.package.app.services.MediaProjectionService.startRecording(MediaProjectionService.java:190)
at com.package.app.services.MediaProjectionService.onStartCommand(MediaProjectionService.java:142)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4085)
at android.app.ActivityThread.access$1800(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7343)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:476)
at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
P.S: This is experienced on Android Q DP5 GSI with target SDK 29. The app works fine with target sdk 28 without any changes.
Don't you forget to add permission <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> into AndroidManifest.xml ?
UPDATE
Make sure you call startForeground() before getMediaProjection()!
The best solution is to call startForeground() from onCreate() without any conditions, displaying some sort of default messages in notification. Then you can execute your logic and call NotificationManager.notify() with updated notification at any time.
Changing the following attributes
android:foregroundServiceType="mediaProjection"
tools:targetApi="q"
in AndroidManifest.xml worked for me.
< service
android:name="SERVICE_NAME"
android:foregroundServiceType="mediaProjection"
tools:targetApi="q"
android:enabled="true"
android:exported="false" />
I want to display the current bucket of my application with a device under Android P beta. Therefore, I try to use the UsageStatsManager class like this :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= 28) {
UsageStatsManager usageStatsManager = (UsageStatsManager) getSystemService(USAGE_STATS_SERVICE);
if (usageStatsManager != null) {
Log.d(TAG, "getAppStandbyBucket():" + usageStatsManager.getAppStandbyBucket());
}
}
}
My Manifest possesses the permission android.permission.PACKAGE_USAGE_STATS :
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
But I encounter a crash when I launch my application :
07-24 10:23:39.061 26967-26967/com.app.bucket E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.bucket, PID: 26967
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.bucket/com.app.bucket.MainActivity}: java.lang.SecurityException: MATCH_ANY_USER flag requires INTERACT_ACROSS_USERS permission at com.android.server.pm.PackageManagerService.getPackageUid:4343 com.android.server.pm.PackageManagerService$PackageManagerInternalImpl.getPackageUid:23964 com.android.server.usage.UsageStatsService$BinderService.getAppStandbyBucket:927 android.app.usage.IUsageStatsManager$Stub.onTransact:274 android.os.Binder.execTransact:731 : Neither user 10118 nor current process has android.permission.INTERACT_ACROSS_USERS.
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: java.lang.SecurityException: MATCH_ANY_USER flag requires INTERACT_ACROSS_USERS permission at com.android.server.pm.PackageManagerService.getPackageUid:4343 com.android.server.pm.PackageManagerService$PackageManagerInternalImpl.getPackageUid:23964 com.android.server.usage.UsageStatsService$BinderService.getAppStandbyBucket:927 android.app.usage.IUsageStatsManager$Stub.onTransact:274 android.os.Binder.execTransact:731 : Neither user 10118 nor current process has android.permission.INTERACT_ACROSS_USERS.
at android.os.Parcel.createException(Parcel.java:1942)
at android.os.Parcel.readException(Parcel.java:1910)
at android.os.Parcel.readException(Parcel.java:1860)
at android.app.usage.IUsageStatsManager$Stub$Proxy.getAppStandbyBucket(IUsageStatsManager.java:658)
at android.app.usage.UsageStatsManager.getAppStandbyBucket(UsageStatsManager.java:479)
at com.app.bucket.MainActivity.onCreate(MainActivity.java:60)
It seems that I missed a permission, but even when I add the following permission :
<uses-permission
android:name="android.permission.INTERACT_ACROSS_USERS"
tools:ignore="ProtectedPermissions" />
I still have the same crash. I was thinking that maybe I miss the runtime call for the permission, but like the documentation stipulate :
NOTE: Most methods on this API require the permission
android.permission.PACKAGE_USAGE_STATS. However, declaring the
permission implies intention to use the API and the user of the device
still needs to grant permission through the Settings application. See
Settings.ACTION_USAGE_ACCESS_SETTINGS. Methods which only return the
information for the calling package do not require this permission.
E.g. getAppStandbyBucket() and queryEventsForSelf(long, long).
It's not necessary. Even knowing that I tried to use the runtime permission, but I still get the crash. If anyone see what is missing, I would really appreciate the help.
I think it's a bug. There is an open issue covering this in the issue tracker: https://issuetracker.google.com/issues/111102580.
so i'm making an app which can upload an image to the server, the web service is good and running and tested with postman.
on The application side, when i tried to add the implementation of the upload service 3.4.2 it's showing me an error, and the app is crashing at the moment of the upload.
here is a screenshot i'm new and not allowed to add pictures,https://i.stack.imgur.com/s3s8x.png
i need fast help please.
here is the run error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.simou.myapplication, PID: 5205
java.lang.RuntimeException: Unable to start service net.gotev.uploadservice.UploadService#c425f01 with Intent { act=net.gotev.uploadservice.action.upload cmp=com.simou.myapplication/net.gotev.uploadservice.UploadService (has extras) }: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3314)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
at net.gotev.uploadservice.UploadService.onStartCommand(UploadService.java:257)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
As mentioned in the error you need to set the namespace for your application as privided the library's wiki
public class Initializer extends Application {
#Override
public void onCreate() {
super.onCreate();
// setup the broadcast action namespace string which will
// be used to notify upload status.
// Gradle automatically generates proper variable as below.
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
// Or, you can define it manually.
UploadService.NAMESPACE = "com.yourcompany.yourapp";
}
}
and register it to your manifest
<application
android:name=".Initializer"
...
>
I've got the below exception trace.
Fatal Exception: java.lang.RuntimeException: Unable to create application com.myapp.MyApplication: java.lang.SecurityException: Unable to start service Intent { cmp=com.myapp/.background.MyService }: Unable to launch app com.myapp/10232 for service Intent { cmp=com.myapp/.background.MyService }: user 0 is restricted
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
at android.app.ActivityThread.access$1600(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1438)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5408)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by java.lang.SecurityException: Unable to start service Intent { cmp=com.myapp/.background.MyService }: Unable to launch app com.myapp/10232 for service Intent { cmp=com.myapp/.background.MyService }: user 0 is restricted
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1728)
at android.app.ContextImpl.startService(ContextImpl.java:1701)
at android.content.ContextWrapper.startService(ContextWrapper.java:516)
at com.myapp.MyApplication.onCreate(MyApplication.java:105)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4685)
at android.app.ActivityThread.access$1600(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1438)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5408)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Any clue on this exception?
Looks like, app is installed from guest user and tried to access in admin account?
I got this exception from OPPO R7 PLUS device.
Manifest:
<?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.myapp">
<application
android:name=".MyApplication"
android:allowBackup="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<service android:name=".background.MyService" />
</application>
</manifest>
Please see post from OPPO:
http://bbs.coloros.com/thread-174655-3-1.html
Below is some translation from the post:
After auto screen off for a while, the system will start battery management module, it will forbid any app start up. but there is a bug, it should force stop the app instead throw exception.
From developer side, they give a solution:
use "try catch" when starting the service.