安全异常崩溃
Security exception crash
我的 android 应用程序正在使用 firebase 并且需要访问互联网,因此在我的清单中我设置了互联网许可,但是 logcat 似乎不这么认为。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.powerofpixels.chipin"
xmlns:android="http://schemas.android.com/apk/res/android">
<permission android:name="android.permission.INTERNET"/>
<application
android:name=".Chipin"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.activities.BirthdayActivity">
</activity>
<activity
android:name=".ui.activities.AuthenticateActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
</application>
</manifest>
错误信息如下:
Process: com.powerofpixels.chipin, PID: 4044
java.lang.SecurityException: Permission denied (missing INTERNET
permission?)
at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at java.net.Socket.tryAllAddresses(Socket.java:109)
at java.net.Socket.(Socket.java:178)
at java.net.Socket.(Socket.java:150)
at javax.net.ssl.SSLSocket.(SSLSocket.java:764)
at
com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186)
at
com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68)
at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317)
at com.firebase.tubesock.WebSocket.run(WebSocket.java:117)
Caused by: android.system.GaiException: android_getaddrinfo failed:
EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.android_getaddrinfo(Native Method)
at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at java.net.Socket.tryAllAddresses(Socket.java:109)
at java.net.Socket.(Socket.java:178)
at java.net.Socket.(Socket.java:150)
at javax.net.ssl.SSLSocket.(SSLSocket.java:764)
at
com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186)
at
com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68)
at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317)
at com.firebase.tubesock.WebSocket.run(WebSocket.java:117)
Caused by: android.system.ErrnoException: android_getaddrinfo failed:
EACCES (Permission denied)
at libcore.io.Posix.android_getaddrinfo(Native Method)
at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at java.net.Socket.tryAllAddresses(Socket.java:109)
at java.net.Socket.(Socket.java:178)
at java.net.Socket.(Socket.java:150)
at javax.net.ssl.SSLSocket.(SSLSocket.java:764)
at
com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186)
at
com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68)
at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317)
at com.firebase.tubesock.WebSocket.run(WebSocket.java:117)
为什么会崩溃?谢谢。
您的清单中需要 uses-permission
而不是 permission
元素。
哦!你有一个小错字!
改变
<permission android:name="android.permission.INTERNET"/>
至
<uses-permission android:name="android.permission.INTERNET" />
是 "uses-permission" 而不是 "permission"。用以下行替换您的权限行
<uses-permission android:name="android.permission.INTERNET" />
我的 android 应用程序正在使用 firebase 并且需要访问互联网,因此在我的清单中我设置了互联网许可,但是 logcat 似乎不这么认为。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.powerofpixels.chipin"
xmlns:android="http://schemas.android.com/apk/res/android">
<permission android:name="android.permission.INTERNET"/>
<application
android:name=".Chipin"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.activities.BirthdayActivity">
</activity>
<activity
android:name=".ui.activities.AuthenticateActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
</application>
</manifest>
错误信息如下:
Process: com.powerofpixels.chipin, PID: 4044 java.lang.SecurityException: Permission denied (missing INTERNET permission?) at java.net.InetAddress.lookupHostByName(InetAddress.java:451) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) at java.net.InetAddress.getAllByName(InetAddress.java:215) at java.net.Socket.tryAllAddresses(Socket.java:109) at java.net.Socket.(Socket.java:178) at java.net.Socket.(Socket.java:150) at javax.net.ssl.SSLSocket.(SSLSocket.java:764) at com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186) at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68) at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317) at com.firebase.tubesock.WebSocket.run(WebSocket.java:117) Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.android_getaddrinfo(Native Method) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) at java.net.InetAddress.lookupHostByName(InetAddress.java:438) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) at java.net.InetAddress.getAllByName(InetAddress.java:215) at java.net.Socket.tryAllAddresses(Socket.java:109) at java.net.Socket.(Socket.java:178) at java.net.Socket.(Socket.java:150) at javax.net.ssl.SSLSocket.(SSLSocket.java:764) at com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186) at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68) at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317) at com.firebase.tubesock.WebSocket.run(WebSocket.java:117) Caused by: android.system.ErrnoException: android_getaddrinfo failed: EACCES (Permission denied) at libcore.io.Posix.android_getaddrinfo(Native Method) at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) at java.net.InetAddress.lookupHostByName(InetAddress.java:438) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) at java.net.InetAddress.getAllByName(InetAddress.java:215) at java.net.Socket.tryAllAddresses(Socket.java:109) at java.net.Socket.(Socket.java:178) at java.net.Socket.(Socket.java:150) at javax.net.ssl.SSLSocket.(SSLSocket.java:764) at com.android.org.conscrypt.OpenSSLSocketImpl.(OpenSSLSocketImpl.java:186) at com.android.org.conscrypt.OpenSSLSocketFactoryImpl.createSocket(OpenSSLSocketFactoryImpl.java:68) at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:317) at com.firebase.tubesock.WebSocket.run(WebSocket.java:117)
为什么会崩溃?谢谢。
您的清单中需要 uses-permission
而不是 permission
元素。
哦!你有一个小错字!
改变
<permission android:name="android.permission.INTERNET"/>
至
<uses-permission android:name="android.permission.INTERNET" />
是 "uses-permission" 而不是 "permission"。用以下行替换您的权限行
<uses-permission android:name="android.permission.INTERNET" />