I'm using Android Studio 2.3.3 and was trying to add a Content Provider component to the project. I keep getting the error "URI Authorities must be a valid URI authority" even after trying many variants of the URI Authorities entry. Same results for a brand new project shown below. Is this working in Studio or is something wrong with the entry?
Asked
Active
Viewed 309 times
1

azizbekian
- 60,783
- 13
- 169
- 249

Hankster
- 422
- 3
- 9
-
Have you tried to remove semicolon `;`? – azizbekian Sep 20 '17 at 10:35
-
Yes. Same error without the semicolon. – Hankster Sep 20 '17 at 10:50
-
Same error without the "content://" and the same error without trailing /info and same error without the trailing "mycontentprovider/info". Even tried "com.example.1" and it still gives me the error. – Hankster Sep 20 '17 at 17:14
-
Tried it again an it worked this time. Will accept the first answer as a correct solution. – Hankster Sep 20 '17 at 21:24
2 Answers
5
It should be without content://
prefix, as simple as com.package.1;com.package.2
:
This will create following <provider>
in AndroidManifest
:
<provider
android:name="com.mydomain.MyContentProvider"
android:authorities="com.example.1;com.example.2"
android:enabled="true"
android:exported="true"></provider>

azizbekian
- 60,783
- 13
- 169
- 249
2
Uri Authority is the string between content://
and the next slash.
A content provider with com.example
authority will handle any Uri starting with content://com.example
.
A content provider cannot specify an Uri Authority that's already present in the system. Such app cannot be installed.
Read more here: https://developer.android.com/guide/topics/providers/content-provider-creating.html#ContentURI

Eugen Pechanec
- 37,669
- 7
- 103
- 124