java.lang.RuntimeException: setAudioSource failed.
11-07 20:30:16.294 12438-12438/com.main.sample W/System.err: at android.media.MediaRecorder.setAudioSource(Native Method)
11-07 20:30:16.294 12438-12438/com.main.sample W/System.err: at com.main.sample.Activity.EventsaddActivity.initializeMediaRecord
In the first step you need to add these permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
set target sdk to 22 or use request permission and set target to 23 or above.
and check your path again
MediaRecorder.setAudioSource(new File("YOUR_PATH"));
Related
I have a problem today. When I try to register to receive a push from Pushwoosh
Pushwoosh.getInstance().registerForPushNotifications()
It throws an exception like that
E/Pushwoosh: Exception occurred
java.lang.IllegalStateException: Application does not define permission com.google.android.c2dm.permission.RECEIVE
at com.pushwoosh.firebase.internal.registrar.a$b.a(Unknown Source:17)
at com.pushwoosh.firebase.internal.registrar.a$b.a(Unknown Source:30)
at com.pushwoosh.firebase.internal.registrar.a.checkDevice(Unknown Source:2)
at com.pushwoosh.notification.PushwooshNotificationManager.a(Unknown Source:45)
at com.pushwoosh.Pushwoosh.a(Unknown Source:23)
at com.pushwoosh.Pushwoosh.lambda$HgkxfkcfE_k-Lm_xVXJ-mTVOJ3g(Unknown Source:0)
at com.pushwoosh.-$$Lambda$Pushwoosh$HgkxfkcfE_k-Lm_xVXJ-mTVOJ3g.a(Unknown Source:6)
at com.pushwoosh.inapp.f.a.a(Unknown Source:11)
at com.pushwoosh.inapp.f.a.lambda$qCb0Pyb8Qrzu-2CtVmkrEeLg1C0(Unknown Source:0)
at com.pushwoosh.inapp.f.-$$Lambda$a$qCb0Pyb8Qrzu-2CtVmkrEeLg1C0.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.os.HandlerThread.run(HandlerThread.java:67)
This is my Manifest
<manifest ..>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application ..> </application></manifest>
I have tried adding this line to my manifest but still not working
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
My device is a Huawei nova 7i, I have tried to settings in my battery follow this link, and still not working. So any solution?
Edit : Huawei Nova i7 no longer supportted by google service, so firebase messaging doesn't work
https://github.com/itinance/react-native-fs
code
import RNFS from 'react-native-fs';
RNFS.mkdir(RNFS.ExternalDirectoryPath + dir)
logcat
05-06 22:43:41.693 W/System.err: java.lang.Exception: Directory could not be created
05-06 22:43:41.697 W/System.err: at com.rnfs.RNFSManager.mkdir(RNFSManager.java:680)
This error occurs after compilation,
But it is normal when debugging,
ok, permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
When i changed target version to 28 i started to get SecurityException crashes when i'm trying to display notification by NotificationManager.notify() from FirebaseService.
I read behavior changes for Android 9, but adding of FOREGROUND_SERVICE permission doesn't help me. The problem occurs on devices with Android 9 only, but i can't reproduce it on Samsung S10.
here is logs:
java.lang.SecurityException:
at android.os.Parcel.createException (Parcel.java:1966)
at android.os.Parcel.readException (Parcel.java:1934)
at android.os.Parcel.readException (Parcel.java:1884)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag (INotificationManager.java:1653)
at android.app.NotificationManager.notifyAsUser (NotificationManager.java:429)
at android.app.NotificationManager.notify (NotificationManager.java:379)
at android.app.NotificationManager.notify (NotificationManager.java:355)
at com.example.Utils.onNotificationReceived (Utils.java:201)
at com.example.FirebaseService.onMessageReceived (FirebaseService.java:51)
at com.google.firebase.messaging.FirebaseMessagingService.zzd (FirebaseMessagingService.java:60)
at com.google.firebase.iid.zzg.run (zzg.java:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run (zza.java:6)
at java.lang.Thread.run (Thread.java:764)
Caused by: android.os.RemoteException:
at com.android.server.am.ActivityManagerService.checkGrantUriPermissionLocked (ActivityManagerService.java:12755)
at com.android.server.am.ActivityManagerService.checkGrantUriPermission (ActivityManagerService.java:12772)
at com.android.server.notification.NotificationRecord.visitGrantableUri (NotificationRecord.java:1147)
at com.android.server.notification.NotificationRecord.calculateGrantableUris (NotificationRecord.java:1123)
at com.android.server.notification.NotificationRecord.<init> (NotificationRecord.java:208)
Manifest permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Could there be an issue in setting sound for channel from raw directory?
I am trying to open a camera on my Cordova app since moving it over to Android Studio and now it has stopped working.
I get no popup of permissions, or anything on the user side to show me otherwise.
I get the following error in the Android Monitor
com.ontrac.nutshellmobile E/ViewRootImpl: sendUserActionEvent() returned.
E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=8324, uid=10182 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:616)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:487)
at android.content.ContentProvider$Transport.query(ContentProvider.java:216)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
at android.os.Binder.execTransact(Binder.java:573)
My manifest has the following permissions
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I am running API 26 for the compile SDK version on the project structure.
My build gradle files contain the SDK versions of
minSdkVersion 23
targetSdkVersion 25
compileSdkVersion 26
buildToolsVersion '26.0.0'
I have tried moving the permissions over to the Cordova Android manifest but no luck. I cant seem to figure out what is causing the error.
Any help would be greatly appreciated. I can give more information if needed.
In order to open camera, you have to install cordova-plugin-android-permissions.
you have to ask for 2 permissions: READ_EXTERNAL_STORAGE and CAMERA, and open the camera in the callback function of the 2 functions.
example of the js code:
function takePicture() {
var permissions = cordova.plugins.permissions;
permissions.requestPermission(permissions.READ_EXTERNAL_STORAGE,
function (status) {
if (!status.hasPermission)
error();
else
permissions.requestPermission(permissions.CAMERA, success.bind(this),
error);
function error() {
console.warn('CAMERA permission is not turned on');
}
}
, error);
function error() {
console.warn('READ_EXTERNAL_STORAGE permission is not turned on');
}
function success(status) {
if (!status.hasPermission)
error();
else
openCamera();
}
}
function openCamera() {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 25,
destinationType: Camera.DestinationType.DATA_URL
});
function onSuccess(imageData) {
var src = "data:image/png;base64," + imageData;
console.log(src);
alert('got picture!!!');
}
function onFail(message) {
alert('error ' + message);
}
}
takePicture();
A user reports on Google Play ONLY 3 times the following error:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10103 nor current process has android.permission.ACCESS_NETWORK_STATE.
at android.os.Parcel.readException(Parcel.java:1327)
at android.os.Parcel.readException(Parcel.java:1281)
at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:597)
(...)
My AndroidManifest.xml contains the following permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CALL_PHONE" />
I think that it's all right because only this user reports this error. But why? It could be a device specific error, or device configuration error? The device is a Galaxy Tab 10.1 (GT-P7500) running Android 4.0.3-4.0.4 (Google Play data)