我尝试从此网站执行此代码:http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/。一切正常,但当我试图查看和添加产品时,模拟器会“不幸的是,MainScreenActivity已停止。
请帮忙吗? :d这是我的logcat文件:
06-26 15:53:16.227: E/AndroidRuntime(1396): FATAL EXCEPTION: AsyncTask #1
06-26 15:53:16.227: E/AndroidRuntime(1396): java.lang.RuntimeException: An error occured while executing doInBackground()
06-26 15:53:16.227: E/AndroidRuntime(1396): at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.lang.Thread.run(Thread.java:856)
06-26 15:53:16.227: E/AndroidRuntime(1396): Caused by: java.lang.IllegalArgumentException: Illegal character in authority at index 15: http://10.0.2.2 /try/get_all_products.php?
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.net.URI.create(URI.java:727)
06-26 15:53:16.227: E/AndroidRuntime(1396): at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
06-26 15:53:16.227: E/AndroidRuntime(1396): at com.example.mainscreenactivity.JSONParser.makeHttpRequest(JSONParser.java:60)
06-26 15:53:16.227: E/AndroidRuntime(1396): at com.example.mainscreenactivity.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:128)
06-26 15:53:16.227: E/AndroidRuntime(1396): at com.example.mainscreenactivity.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:1)
06-26 15:53:16.227: E/AndroidRuntime(1396): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-26 15:53:16.227: E/AndroidRuntime(1396): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-26 15:53:16.227: E/AndroidRuntime(1396): ... 3 more
06-26 15:53:16.570: W/ActivityManager(276): Force finishing activity com.example.mainscreenactivity/.AllProductsActivity
06-26 15:53:16.737: W/WindowManager(276): Failure taking screenshot for (266x425) to layer 21020
答案 0 :(得分:0)
您在ip地址后面有一个空格字符:http://10.0.2.2*/