Sorry if my Question is kind of noob, just beginning to delve into Android prog. I tried to run the custom camera code taken from github
However, the app crash upon run. Logcat: java.lang.RuntimeException: Fail to connect to camera service indicates that it is due to the camera permission. I already added the camera permission in the android manifest file before, it is still showing same error.
I added permission in the android manifest as shown below;
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CALL_PHONE" />
Any clue?
Thanks in advance.
Related
Showing error while running in esc_pos_bluetooth in flutter I added permission in manifest page like this.
<uses-permission android: name="android.permission.BLUETOOTH" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.BLUETOOTH_SCAN" tools:targetApi="31" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" android:maxSdkVersion="31" tools:targetApi="donut" /> <uses-permission android: name="android.permission.ACCESS_COARSE_LOCATION" />.
And still having the error.
Error starting scan. E/flutter (16326): [ERROR: flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Platform Exception(startscan, Need android.permission.BLUETOOTH_SCAN permission for android.content.AttributionSource#8a7ab34e: GattService register Scanner, null, null).
this problem is only showing in android 10 or above devices only. under android 10 version phones support this smoothly and showing near devices also.
Using 0.4.1 with the following manifest on a real device works for me:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
What you are missing is the uses-feature flag. Check it out here
You can also read about hickups für Bluetooth < 12.0 on Android here
I would like to use my webcam in the android camera.
I've checked out this stack overflow post: Android: How to use webcam in emulator? but when I complete the steps in the accepted answer...
I keep getting the error, "Camera keeps crashing."
In my Manifest file, I've declared the following permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera2.full" />
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera2.front"/>
Any idea why the camera keeps crashing?
Thanks!!
After doing lots of research,
I found out that android simply required a reboot. If this doesn't work for anyone else, try deleting your emulator and re-installing it.
i want to publish my android app on amazon but it gives me the error "No device supported". i have defined the minSdkLevel in manifest file.
please give me any solution for that. Here is manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.abc"
android:versionName="1.2.1"
android:versionCode="4">
<uses-sdk android:minSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus"/>
.
.
.
.
I had some issues regarding this on the play and when I was searching for suggestions came across this post that saved my day. Maybe it will help you too
In an application that I recently uploaded at Google Play there are reports of some users that the application can not even executed. In particular it is reported that this happens at
Samsung S4
LG Nexus 4
Sony Xperia Z2
Samsung Note 1 (N7000) (ANDROID 4.1.2)
The permissions of the app are
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
and
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
A possible code incompatibility maybe is on the file functions since the application checks for a particular folder to exist every time that it executes and try to create it if it is not exist. However, since I do not have access at that devices, I can not be sure of anything.
So the question is:
Is there any particular restrictions on that devices concerning the permissions of the application? What could be the problems in the code that creates this problematic behaviour?
Thank you in advance for any hints or advices.
The problem was at the third line of the MainActivity where I declared that the application will appear in landscape mode...
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
For a reason I do not understand that line created a memory overflow in some devices and the application was instantly crashed. I manage to find the faulty code by try and error when I created a Nexus 5 API 22 x86 virtual device and reproduce this situation.
The solution was to remove the above faulty line and type
android:screenOrientation="landscape"
in the AndroidManifest.xml file.
I have published an app on Google Play Store but when I try to download it on Tablet, it says, app is not compatible.
Also, in developer console, I get this message: Your layout should make use of the available space on 7-inch tablets
Now, 1st thing , I want to lock app to only portrait orientation and hence screen usage will be almost same.
Here's the link of the app.
Some imp info about the app:
android:minSdkVersion="10"
android:largeScreens="true" AND android:xlargeScreens="true"
To support Tablets, android docs says, check if minSdkVersion is declared with value 11 or higher. , but what if I want to support devices with OS 2.3.3 ?
Please give appropriate advice.
Edit
Is this ok?
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" android:required="false"/>
<uses-permission android:name="android.permission.READ_CONTACTS" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Edit 2
After updating permissions part of manifest file as following, app is showing up in tabs also:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" />
it says, app is not compatible.
It is showing error on device not only because minSDKversion but also google play concern about your given permission on the manifest file as well.
Like if you entered something like:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Your tab will not support it.
So instead of using uses-permission use <uses-feature>. And in java file check for it that your needed hardware is available or not.
For <uses-feature> see the below link:
http://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference
Edited:
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
<uses-permission android:name="android.permission.SEND_SMS" android:required="false"/>
<uses-permission android:name="android.permission.READ_CONTACTS" android:required="false"/>
Nope you can't give permission like this because uses-permission not allowed android:required="false". Although It will not through any error it will not work.
If you will use <uses-feature> it will take the permission to access the specific hardware.
So use this:
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
And not to forget to check this feature availability in your java code. If you will not check it, CAMERA, SEND_SMS wont work in your app.
To check camera availability use this:
import android.content.pm.PackageManager;
PackageManager pm = context.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// Do you camera work here.
}