在我的项目中包含Scringo库之后,实现了QuickStart指令:
private Scringo scringo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Scringo.setAppId("<MY_SCRINGO_APP_ID>");
scringo = new Scringo(this);
scringo.init();
scringo.addSidebar();
}
@Override
protected void onStart() {
super.onStart();
scringo.onStart();
}
@Override
protected void onStop() {
super.onStop();
scringo.onStop();
}
我合并Manifest.xml以获取权限,并设置新按钮以打开Scringo菜单。 运行应用程序后,单击按钮打开Scringo菜单时,出现错误:
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoHttpFetcher.getResponseStr(ScringoHttpFetcher.java:132)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.handleResponse(ScringoJsonFetcher.java:59)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.run(ScringoJsonFetcher.java:40)
12-21 18:59:31.275: E/Scringo(5573): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
12-21 18:59:31.275: E/Scringo(5573): at libcore.io.Posix.getaddrinfo(Native Method)
12-21 18:59:31.275: E/Scringo(5573): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
12-21 18:59:31.275: E/Scringo(5573): at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
12-21 18:59:31.275: E/Scringo(5573): ... 18 more
12-21 18:59:31.275: E/Scringo(5573): Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
12-21 18:59:31.275: E/Scringo(5573): ... 21 more
12-21 18:59:31.275: E/Scringo(5573): Error fetching
12-21 18:59:31.275: E/Scringo(5573): java.lang.SecurityException: Permission denied (missing INTERNET permission?)
12-21 18:59:31.275: E/Scringo(5573): at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
12-21 18:59:31.275: E/Scringo(5573): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
12-21 18:59:31.275: E/Scringo(5573): at java.net.InetAddress.getAllByName(InetAddress.java:214)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
12-21 18:59:31.275: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoHttpFetcher.getResponseStr(ScringoHttpFetcher.java:132)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.handleResponse(ScringoJsonFetcher.java:59)
12-21 18:59:31.275: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.run(ScringoJsonFetcher.java:40)
12-21 18:59:31.275: E/Scringo(5573): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
12-21 18:59:31.275: E/Scringo(5573): at libcore.io.Posix.getaddrinfo(Native Method)
12-21 18:59:31.275: E/Scringo(5573): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
12-21 18:59:31.275: E/Scringo(5573): at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
12-21 18:59:31.275: E/Scringo(5573): ... 18 more
12-21 18:59:31.275: E/Scringo(5573): Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
12-21 18:59:31.275: E/Scringo(5573): ... 21 more
12-21 18:59:34.305: E/Scringo(5573): Error fetching
12-21 18:59:34.305: E/Scringo(5573): java.lang.SecurityException: Permission denied (missing INTERNET permission?)
12-21 18:59:34.305: E/Scringo(5573): at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
12-21 18:59:34.305: E/Scringo(5573): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
12-21 18:59:34.305: E/Scringo(5573): at java.net.InetAddress.getAllByName(InetAddress.java:214)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
12-21 18:59:34.305: E/Scringo(5573): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
12-21 18:59:34.305: E/Scringo(5573): at com.scringo.utils.ScringoHttpFetcher.getResponseStr(ScringoHttpFetcher.java:132)
12-21 18:59:34.305: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.handleResponse(ScringoJsonFetcher.java:59)
12-21 18:59:34.305: E/Scringo(5573): at com.scringo.utils.ScringoJsonFetcher.run(ScringoJsonFetcher.java:40)
12-21 18:59:34.305: E/Scringo(5573): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
12-21 18:59:34.305: E/Scringo(5573): at libcore.io.Posix.getaddrinfo(Native Method)
12-21 18:59:34.305: E/Scringo(5573): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
12-21 18:59:34.305: E/Scringo(5573): at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
12-21 18:59:34.305: E/Scringo(5573): ... 18 more
12-21 18:59:34.305: E/Scringo(5573): Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
12-21 18:59:34.305: E/Scringo(5573): ... 21 more
.
.
.
请帮助......
答案 0 :(得分:2)
更仔细地检查日志,您将看到需要为AndroidManifest.xml添加INTERNET权限:
<uses-permission android:name="android.permission.INTERNET" />
答案 1 :(得分:1)
当您将Scringo项目库设置为项目的依赖项,并在project.properties中设置manifestmerger.enabled=true
时,它会将您的清单与Scringo清单合并。在Scringo清单中,已添加INTERNET权限。如果合并中存在某种错误,您将在Eclipse控制台中看到它。
合并后的清单应该在您的bin文件夹中,看看那里是否正确合并以及是否存在INTERNET权限。
BTW,有时“清理”项目有帮助; - )