I have this exception in my app, under warnings in the Logcat.
The app is a system app.
java.lang.reflect.InvocationTargetException
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at netchanger.tawkon.com.lib.network.NetworkChanger.setPreferredNetwork(NetworkChanger.java:48)
W/System.err: at netchanger.tawkon.com.lib.network.NetworkChanger.setPreferredNetwork(NetworkChanger.java:36)
W/System.err: at netchanger.tawkon.com.lib.services.LocationMonitorService.stopService(LocationMonitorService.java:57)
W/System.err: at com.tawkon.data.lib.service.KeepAliveService$PowerReceiver.onReceive(KeepAliveService.java:154)
W/System.err: at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52497(LoadedApk.java:1313)
W/System.err: at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
W/System.err: at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
W/System.err: at android.os.Handler.handleCallback(Handler.java:790)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err: at android.os.Looper.loop(Looper.java:164)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6494)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
W/System.err: Caused by: java.lang.SecurityException: No Carrier Privilege.
W/System.err: at android.os.Parcel.readException(Parcel.java:2005)
W/System.err: at android.os.Parcel.readException(Parcel.java:1951)
W/System.err: at com.android.internal.telephony.ITelephony$Stub$Proxy.setPreferredNetworkType(ITelephony.java:4237)
W/System.err: at android.telephony.TelephonyManager.setPreferredNetworkType(TelephonyManager.java:4821)
W/System.err: ... 15 more
I see that this is InvocationTargetException and it's caused by SecurityException.
What does 'No Carrier Privilege.' mean? How can I avoid this?
Security Exception implies there is a permission required to which the user hasn't granted. Ensure you request for the correct permission and confirm that the user has granted the permission before execution of the functionality.
Read on telephony manager
As per the android documentation in order to use android.telephony.TelephonyManager.setPreferredNetworkType() method your app should have carrier privileges.
Carrier Privileges in a gist:
Android grants special privileges to apps from Mobile (Virtual) Network Operator (MNO/MVNOs) via UICC to override certain carrier configurations (e.g. IMS settings) on the device. This app from operator is signed with a signing key whose hash value is stored in UICC, which is in-turn read by Android Platform to allow the app to make calls to handful of special APIs
More information related to how to give your app carrier privileges can be found here. The link explains the method to override IMS settings using carrier privileges but it can be applied to whatever functionality you are trying to achieve
Related
The Google SignIn inside my Android app runs perfectly well (I can sign in using any Google accounts on the phone) when I compiled the code in my daily-laptop. But when I cloned the code in my other laptop and compiled it there, it will always return Code 10 error.
Here's the full e.printStackTrace()
W/System.err: com.google.android.gms.common.api.ApiException: 10:
W/System.err: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source:4)
W/System.err: at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source:8)
W/System.err: at com.imincode.earthlings.view.ui.Register.onActivityResult(Register.kt:443)
W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:8110)
W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:4839)
W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4887)
W/System.err: at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
W/System.err: at android.os.Looper.loop(Looper.java:214)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7403)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
In my console.developers.google.com Project Credentials, under Application restrictions I chose Android apps and I've triple confirmed that I put the correct SHA-1 signing-certificate fingerprint from both my daily computer and this other laptop.
Edit: And I can confirm that google-services.json is there under app folder on both machine.
The solution is to add the SHA Key to your project in your firebase , Go To :
Project Overview -> Click on Settings Icon -> Project Settings -> General -> Scroll down under your package name -> Add your SHA key
I am having two applications, let A and B. There is ContentProvider in A, with manifest declaration as follows,
<provider
android:name=".LogProvider"
android:authorities="com.xxx.LogProvider"
android:grantUriPermissions="true"
android:permission="android.permission.READ_XXX_LOGS"
android:enabled="true"
android:exported="true"
android:multiprocess="true"/>
Application B is receiving ContentResolver for the same. And App B have corresponding also. But, whenever there is an Entry to content provider in App A,
App B is receiving its onChange event. But, is having the following error.
I/XTSipListener: onChange, uri = content://com.xxx.LogProvider/error_logs/1
E/XTSipListener: onChange, SecurityException: Permission Denial: opening provider com.xxx.LogProvider from ProcessRecord{bb1084b 22087:com.xxx.AppB/u0a210} (pid=22087, uid=10210) requires android.permission.READ_XXX_LOGS or android.permission.READ_XXX_LOGS
W/System.err: java.lang.SecurityException: Permission Denial: opening provider com.xxx.LogProvider from ProcessRecord{bb1084b 22087:com.xxx.AppB/u0a210} (pid=22087, uid=10210) requires android.permission.READ_XXX_LOGS or android.permission.READ_XXX_LOGS
W/System.err: at android.os.Parcel.readException(Parcel.java:1712)
W/System.err: at android.os.Parcel.readException(Parcel.java:1662)
W/System.err: at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:4935)
W/System.err: at android.app.ActivityThread.acquireProvider(ActivityThread.java:6083)
W/System.err: at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2468)
W/System.err: at android.content.ContentResolver.acquireProvider(ContentResolver.java:1476)
W/System.err: at android.content.ContentResolver.acquireContentProviderClient(ContentResolver.java:1551)
W/System.err: at com.xxx.AppB.contentobservers.XTSipListener.onChange(XTSipListener.java:86)
W/System.err: at android.database.ContentObserver.onChange(ContentObserver.java:145)
W/System.err: at android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:216)
W/System.err: at android.os.Handler.handleCallback(Handler.java:751)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:154)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6816)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
E/XTSipListener: onChange: cur = NULL
AppB have target version 22. Which cant be upgraded due to some other functionalities.
When attempting to run the BLE Indoor Positioning Demo App on Android Things (using the NXP i.MX7D Developer Kit), I get Bluetooth scanning error: Location Services disabled (code 4).
E/BluetoothClient: Bluetooth scanning error: Location Services disabled (code 4)
W/System.err: com.polidea.rxandroidble.exceptions.BleScanException: Location Services disabled (code 4)
W/System.err: at com.polidea.rxandroidble.internal.scan.ScanPreconditionsVerifierApi18.verify(ScanPreconditionsVerifierApi18.java:31)
W/System.err: at com.polidea.rxandroidble.internal.scan.ScanPreconditionsVerifierApi24.verify(ScanPreconditionsVerifierApi24.java:38)
W/System.err: at com.polidea.rxandroidble.RxBleClientImpl$1.call(RxBleClientImpl.java:114)
W/System.err: at com.polidea.rxandroidble.RxBleClientImpl$1.call(RxBleClientImpl.java:111)
W/System.err: at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
W/System.err: at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
W/System.err: at rx.Observable.subscribe(Observable.java:10352)
W/System.err: at rx.Observable.subscribe(Observable.java:10319)
W/System.err: at rx.Observable.subscribe(Observable.java:10227)
W/System.err: at com.nexenio.bleindoorpositioningdemo.bluetooth.BluetoothClient.startScanning(BluetoothClient.java:79)
W/System.err: at com.nexenio.bleindoorpositioningdemo.HomeActivity.onResume(HomeActivity.java:108)
W/System.err: at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)
W/System.err: at android.app.Activity.performResume(Activity.java:7118)
W/System.err: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)
W/System.err: at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862)
W/System.err: at android.app.ActivityThread.-wrap11(Unknown Source:0)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:164)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6494)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
The app uses RxAndroidBle for dealing with Android's Bluetooth stack. It also declares these permission in the manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
As of my understanding, Android Things should automatically grant these permissions at install time or after a reboot.
I don't know how I should enable the location services manually or programatically.
The issue is not with permissions. The RxAndroidBle library makes some assumptions about location services that aren't necessarily appropriate for Android Things (since those settings aren't actually controlled by users). The reason the library check is failing is because NETWORK_PROVIDER is not enabled and GPS_PROVIDER is only enabled if you have a GPS driver registered. You don't actually need either of those to do a BLE scan, however.
Fortunately for you, it looks like the author of RxAndroidBle recently changed the code to also verify if the location mode settings were enabled. This check will pass on Android Things, so in your case you probably only need to update your library dependency to 1.5:
dependencies {
...
implementation "com.polidea.rxandroidble:rxandroidble:1.5.0"
}
I know this type of question has been asked before and i have gone through this but still facing this issue. I was using this example . But while i run my code i got following exception
Failed to detect whether we are running on Google Compute Engine.
java.net.ConnectException: Failed to connect to /169.254.169.254:80
at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:143)
at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:104)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
at com.google.auth.oauth2.ComputeEngineCredentials.runningOnComputeEngine(ComputeEngineCredentials.java:191)
at com.google.auth.oauth2.DefaultCredentialsProvider.tryGetComputeCredentials(DefaultCredentialsProvider.java:270)
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentialsUnsynchronized(DefaultCredentialsProvider.java:194)
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:112)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:127)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:100)
at com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:53)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:134)
at com.google.cloud.dialogflow.v2.stub.GrpcSessionsStub.create(GrpcSessionsStub.java:75)
at com.google.cloud.dialogflow.v2.stub.SessionsStubSettings.createStub(SessionsStubSettings.java:100)
at com.google.cloud.dialogflow.v2.SessionsClient.(SessionsClient.java:132)
at com.google.cloud.dialogflow.v2.SessionsClient.create(SessionsClient.java:114)
at com.google.cloud.dialogflow.v2.SessionsClient.create(SessionsClient.java:106)
at com.example.lpt_0096.dialogflowv2.MainActivity$MyAsync.detectIntentStream(MainActivity.java:76)
at com.example.lpt_0096.dialogflowv2.MainActivity$MyAsync.doInBackground(MainActivity.java:61)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
W/System.err: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
W/System.err: at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:119)
W/System.err: at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:127)
W/System.err: at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:100)
W/System.err: at com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:53)
W/System.err: at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:134)
W/System.err: at com.google.cloud.dialogflow.v2.stub.GrpcSessionsStub.create(GrpcSessionsStub.java:75)
W/System.err: at com.google.cloud.dialogflow.v2.stub.SessionsStubSettings.createStub(SessionsStubSettings.java:100)
W/System.err: at com.google.cloud.dialogflow.v2.SessionsClient.(SessionsClient.java:132)
W/System.err: at com.google.cloud.dialogflow.v2.SessionsClient.create(SessionsClient.java:114)
W/System.err: at com.google.cloud.dialogflow.v2.SessionsClient.create(SessionsClient.java:106)
W/System.err: at com.example.lpt_0096.dialogflowv2.MainActivity$MyAsync.detectIntentStream(MainActivity.java:76)
W/System.err: at com.example.lpt_0096.dialogflowv2.MainActivity$MyAsync.doInBackground(MainActivity.java:61)
W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err: at java.lang.Thread.run(Thread.java:764)
from where can i set environment variable in android studio, I am windows user
From the error
java.io.IOException: The Application Default Credentials are not
available. They are available if running in Google Compute Engine.
Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS
must be defined pointing to a file defining the credentials
See
https://developers.google.com/accounts/docs/application-default-credentials
for more information.
You may need to add this in the environment variable path GOOGLE_APPLICATION_CREDENTIALS=path/to/your/service_accont_key_file.json. And should get the json file from here https://cloud.google.com/docs/authentication/getting-started . Also if you don't know how to set environment variable path you can check this https://www.computerhope.com/issues/ch000549.htm
I am implementing Facebook Login in my App but its not working on Api 2.3.6
I have tested the App in Emulator and its working Fine upto Api 23
Also it's working in Device with API 21 but not in 2.3.6
The Error is related to SSL
Bcoz I have read in an SO answer that,
in Api level 2.3.6 all connections and authorizations are handled by HTTPS only
while in Api levels above 2.3.6 its not the HTTPS that does every task
Also I have noticed that whenever I am trying to call any URL starting
with HTTPS it's not giving the final result but gets silently stopped as was the case
with Googles Direction Api.
Below is the StackTrace I am getting in 2.3.6 :
V/webkit: LoadListener.handleSslErrorRequest():
url:https://m.facebook.com/v2.4/dialog/oauth?
return_scopes=true&response_type=token%2Csigned_request&redirect_uri
=fbconnect%3A%2F%2Fsuccess&display=touch&sdk=android-
4.5.1&e2e=%7B%22init%22%1232%7D&client_id=1234&default_audience=friends
primary error: 3 certificate: Issued to: CN=*.facebook.com,O=Facebook\,
Inc.,L=Menlo Park,ST=CA,C=US;
Issued by: 1.2.840.113549.1.9.1=#1223,CN=Cyberoam SSL
CA_C016700030,OU=Cyberoam Certificate
Authority,O=Elitecore,L=Ahmedabad,ST=Gujarat,C=IN;
I/System.out: close [socket][/0.0.0.0:52994]
I/webkit/webview: WebView.stopLoading()
D/webkit/webview: WebView.stopLoading(): webcorethread is initialized
I/webkit/webview: WebView.stopLoading()
D/webkit/webview: WebView.stopLoading(): webcorethread is initialized
W/System.err: at
com.facebook.login.LoginManager.onActivityResult(LoginManager.java:173)
W/System.err: at
com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:139)
W/System.err: at
com.facebook.internal.CallbackManagerImpl.onActivityResult
(CallbackManagerImpl.java:82)
W/System.err: at
com.hogo.integrationapp.FirstActivity.onActivityResult
(FirstActivity.java:179)
W/System.err: at
android.app.Activity.dispatchActivityResult(Activity.java:3975)
W/System.err: at
android.app.ActivityThread.deliverResults(ActivityThread.java:2629)
W/System.err: at
android.app.ActivityThread.handleSendResult(ActivityThread.java:2675)
W/System.err: at
android.app.ActivityThread.access$2000(ActivityThread.java:156)
W/System.err: at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1030)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:130)
W/System.err: at android.os.Looper.loop(SourceFile:351)
W/System.err: at
android.app.ActivityThread.main(ActivityThread.java:3821)
W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err: at java.lang.reflect.Method.invoke(Method.java:538)
W/System.err: at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run\
(ZygoteInit.java:969)
W/System.err: at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
W/System.err: at dalvik.system.NativeStart.main(Native Method)
Is there any Easy way to solve it ?
Also I want to understand why this is happening ?
I am using Facebook Sdk 4.5.1
For API 4.4.2 :
The Error was due to a File Transfer App open in my Device, when i closed it the error was gone
Thanks in Advance...