java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission - android-bluetooth

Has anyone meet the same problem as the following error message shows when calling bluetoothDeive.createBond() method with android 4.4 api?
java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission
Note: BLUETOOTH_ADMIN permission is already included in AndroidManifest file.

Got the exact error message.
Took me an hour to realize that the bluetooth on the phone is not enabled. After turning it on, it works as expected.

You can't use this permission if your app is a third party app (non-system app). To learn more, see Android API: BLUETOOTH_PRIVILEGED

I run on this error, and only I can say, you need to install your app as a system privileged app, to go to system folder and try to copy app to the app folder or priv_app folder. On my Android platform, when I made folder inside priv_app folder for my app and copied my apk to it and restarted Android, everything worked OK.
I my case I added in manifest all this permissions at the beginning, but it worked only after this step above.

Try this:
1) remove "android.permission.BLUETOOTH_PRIVILEGED" from your permissions.
2) remove "android.permission.BLUETOOTH".
3) add "android.permission.BLUETOOTH_ADMIN" and just that.
The reference says that is the only permission needed.https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#createBond()
EDIT: if you already included "bluetooth_admin", maybe its a platform problem.They may have not supported that functionality earlier. Maybe you should target a higher min-sdk-platform , Im using Android 20 as the minimum (but never tried that function).

try this in your manifest
<user-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
notice the user not uses-permission on the first line. Until I switched that, For some reason I kept getting
java.lang.SecurityException: Need BLUETOOTH_ADMIN permission

Related

Getting an "Access Denied" error when I reload my React app on AWS Amplify

I am working on a React app that's running on AWS Amplify. My React app is using the react-router-dom library to route to different components. After running amplify publish in the CLI, at the root of the app (obktraining.com) everything is fine in the browser, I can also route to other components in the app just fine as well. But when I refresh my browser while I am on a route (obktraining.com/menu), I get an Access Denied error message.
I have found other posts about similar issues regarding rewrites and redirects in Amplify, but the solutions given do not work for me.
Here is an image of the error:
My Amplify app rewrites & redirects :
Again, the error only displays when I refresh on a route (obktraining.com/menu or obktraining.com/drinks) not on obktraining.com. Is the issue being caused by the react-router-dom library or is it an issue with Amplify settings? I am not sure where to go from here.
I have been facing the same error since days.The error is being caused by the amplify settings. The solution is simple,
Edit your Rewrites and redirects by adding a new rule.
source address = </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
target address = /index.html
status = 200 (Rewrite)
Country code can be left blank
Save and try refreshing your app again. It should probably work.
use this for reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
Then you can just put in (as Dhruv Godambe posted above)
</^((?!.(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$).)*$/>
as the Source address and
/index.html as your target address
You can navigate to 'rewrites and redirects' in your app from AWS Amplify console and click on edit and select open text editor, and add this piece of code in your array(if present) else put the array braces around it.
{
"source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",
"target": "/index.html",
"status": "200",
"condition": null
}
Reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
Reference:
https://docs.aws.amazon.com/amplify/latest/userguide/manual-deploys.html
I have faced the same problem.
I was using Manual Zip File (Compressed) download (wrong).
Here is how to deploy manually correctely:
Run this command
npm run build
Now a build folder will be created.
2. Compress the content of this folder
Not the content of the whole project.
You chnage directory to the build folder and Compress the content in side.
3. Upload that compressed file Inside the build directory
Now this should work just fine.
:)
The correct rule should be like this:
Source address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address: /index.html
Status: 200
I was getting the an Access Denied error message too. The error went away when I followed the documentation described in the answer above, but then I got the white screen problem described above too.
Reviewing the steps I noticed the auto-complete for the "Destination Address" listed in the "Rewrites and redirects" settings was /. When I tried using / as the "Destination Address" instead of /index.html I no longer got the white screen and got the expected page content.
Sharing what I found in case this helps others who are seeing a white screen after fixing the error with the rewrite rule described in the answers above. (Note as of Nov 2022 the "Rewrites and redirects" setting page uses the wording "Target Address" instead of "Destination Address".)
I have faced the same problem. I was zipping build folder, but not the contents within the zip folder.
Here is how I fixed it:
Run build command
npm run build
Now a build folder will be created inside your project directory.
Open build folder.
Compress the contents of build folder, and not build folder.
Now upload this new zip created from sub files and folders from build folder.
App will run fine on AWS Amplify.
I got the same error,
I zipped the build folder first then uploaded it and got that error,
but when I just uploaded the folder without zipping it, it worked fine !! weird!!
in my application I used the port 8080

service worker canceling out REST urls

just started working with reactjs recently, month or two..not a pro but can find my way around.. I am using create ract app (quickie ,that ships with service-worker) and my setup is such that I am deploying react app in the root of my java REST application, so all my service rest calls are in relative format, e.g /rest/myservice/123 etc.. and they work just fine..
but recently I started getting strange errors, and rest calls stopped working..
if I execute RET URL from browser .... nothing happens index loads... when I test with postman REST works just fine it also works in safari or if url is localhost... ...so after hours of frustration i discovered that service worker doing its .... caching . my rest calls are getting intercepted and they never make it to server... and there is nowhere that it mentions about how to overcome it, neither in service worker docs nor in create-react-app docs ...nothing is mentioned about this use case...... this is so pathetic...
I figured it out after numerous trail and errors... but it did not stop there..
I went ahead and deleted the service-worker registration entry from index.js also deleted service-worker file and rebuild the app. well service-worker.js file is still there... it showed up in build folder after I rebuild the project..... what is it with create-react-app did they got paid by google to include service-worker? or what is going on? why can not I remove it? and how do I prevent it from canceling my rest url calls?
when I type : https://xxxx.io/x/referal/refCode/3429878 it just loads application...
what else am I missing?
got the answer over #Redit needed to unregister worker...
details #:
https://www.reddit.com/r/reactjs/comments/8hovvb/removal_of_serviceworker_from_reactjs_app/

Custom domain using create-react-app for github pages

I'm not sure what I'm doing wrong. i've followed all the steps to set up a custom domain name, but maybe I'm missing something.
I followed the steps in this article so my settings look like this:
A Record # 192.30.252.153 Automatic
A Record # 192.30.252.154 Automatic
CNAME Record www myusername.github.io. Automatic
I added a CNAME file which only has my domain name in it.
I added the CNAME file to the public folder of my react app as the instructions here state.
I went to my github settings and set the domain name. It currently has a checkmark saying that my site has been published.
Going to my site here gives a 404 error. What else am I supposed to do?
I had a similar issue when trying to set a custom domain with create-react-app on a github project page.
An easy solution worked for me is:
Add a "CNAME" file in the "public" folder with only the domain in this file(start with "www" without "https://");
Change the homepage in the "package.json" file from "https://xxx.github.io/xxx" to your domain that you put in the "CNAME" file with "https://";
In Git Bash, follow the basic steps 'git add .', 'git commit -m "change"', 'git push origin master' to update the changes;
In Git Bash still, run "npm run deploy", then type the domain in your browser (clear previous history), it should show up the lovely "welcome to React" page.
Regards,
It is definitely not giving a 404. It seems some of the links to your loaded js/css files are malformed, but the index.html is loading just fine.
You should keep in mind that your ISP and your computer both try to cache information about where a given domain name should route to. This can sometimes mean that the path to the destination IP is cached and will show you the out of date resource immediately after a new CNAME is added.
Most ISPs guarantee a refresh of the related cache within 48 hours. If you need to check faster than that, I would try to find a different internet connection and device to use to access the page after you have everything set up. Smart Phones are invaluable for this, just make sure the wifi is turned off.

Local GAE Datastore is empty after restart on OSX

I'm building a Google App Engine application with a Go backend + Polymer frontend. As a result, I'm using a dispatch.yaml file to serve both at the same time.
The problem I'm facing is that the datastore is empty when I restart my computer. I've tested this on both OSX 10.9.5 and 10.10.4. Both exhibit the same response upon a system reboot. Windows 7, however, seems to hold on to the data.
The documentation suggests that data should persist, since I'm not explicitly calling a clear. It's not. I've tried to set the datastore location myself using this:
dev_appserver.py --datastore_path=~/go_apps/data ~/go_apps/my_app
I'm receiving this error:
google.appengine.tools.devappserver2.errors.AppConfigNotFoundError: "/Users/anthony/go_apps/my_app is a directory but does not contain app.yaml or app.yml
Obviously, since I'm using a dispatch.yaml file, it wouldn't. So, since the backend, which handles the data, does have an app.yaml file, I try to set it there. I use this command:
dev_appserver.py --datastore_path=~/go_apps/data ~/go_apps/my_app/backend
That doesn't seem to work either, as I get this error:
sqlite3.OperationalError: unable to open database file
Okay? Well, not sure where to turn now. From what I could gather from other posts, that data is stored temporarily. But, I can't seem to set a custom, non-temporary location for the data. So, now I'm populating a datastore every time I reboot, which seems ridiculous.
* Edit *
I've tried the following, which seems like it tries to launch the app, and creates a datastore.db file at the correct location:
dev_appserver.py --datastore_path ~/go_apps/my_app/data/datastore.db ~/go_apps/my_app/dispatch.yaml ~/go_apps/my_app/backend/app.yaml ~/go_apps/my_app/frontend/app.yaml
However, I'm getting a weird error now:
/var/folders/04/3hxnpxc15wj2k4v40lkdncd00000gn/T/tmpkcQYnFappengine-go-bin/backend.go:13: can't find import: "github.com/gorilla/mux"
Does Go build to that folder temporarily? That import is definitely available, and always builds fine calling goapp serve.
Here is what my imports look like on backend.go
import (
//standard library
"fmt"
"net/http"
"time"
"log"
//third party
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"github.com/dgrijalva/jwt-go"
"golang.org/x/crypto/bcrypt"
//my imports
"github.com/section14/go_polymer_comm_pkg/controller"
)
You have to pass the name of the file to be used as the persisted datastore, not a folder.
And next provide the folder of your app (which contains app.yaml). Don't mix the 2. So it should be something like:
dev_appserver.py --datastore_path=~/my_app/my_app.db ~/go_apps/my_app
Details can be found here:
The Go Development Server / Using the Datastore
Notes:
The default datastore file is in the temp folder, and your OS-X most likely clears that on system restart, that's why it is not preserved for you. On the other hand Windows 7 for example does not clear the temp folder on system restarts.
Got it up and running by adding both GOPATH and GOROOT environment variables to my .bash_profile. In total, these three paths (first path was already set) are needed for it to run:
# Add Google AppEngine path
export PATH=/Users/anthony/go_appengine:$PATH
# GOPATH
export GOPATH=/Users/anthony/go_appengine/gopath
export PATH=$PATH:$GOPATH
# GOROOT
export GOROOT=/Users/anthony/go_appengine/goroot
export PATH=$PATH:$GOROOT
This command is called from inside the project folder (mine resides outside of the appengine folder) for it to launch:
dev_appserver.py --datastore_path data/datastore.db dispatch.yaml backend/app.yaml frontend/app.yaml
Notice that the .yaml files are still there. It builds fine with them, and probably builds fine without them if you don't need a dispatch.yaml file.
Thanks #icza for the direction. Wanted to organize the steps in a post for easier reading.

CakePHP 1.3.0 RC4 Installation

I have been using 1.2.6 and downloaded 1.3 to try it out. I am using wampserver with Apache 2.2.11. I have mod rewrite enabled. When I bake a new application using the cake 1.3 console, after I verify that the webroot/index.php of the application CAKE_CORE_INCLUDE_PATH is set to the Cake1.3 Installation folder. The result is a page thats missing CSS, missing a method. Typing in localhost/app/index.php will enable the program to find the app. Therefore I have to assume the rewrite module isnt functioning properly for v1.3. Is there something I have to add to the cake installation or app folder to make this function as it should?
No, Cake is set up properly from the start. The thing that always trips me up is that I forget to set my Apache virtual host's AllowOverride value to All. This allows the .htaccess file to be read.
Are there any error messages in your apache error logs?
Did you replace the previous application's directory with the new one? If not, you may need to add a tag with the appropriate AllowOverride permissions set inside your httpd.conf file, to allow mod rewrite to execute.
Can you load /css/style.css in your browser or does it give a 404?
This may sound like a silly question, but after you made your changes to AllowOverride in your Apache configuration, did you restart Apache?

Resources