您的位置:首页 > 移动开发

java.lang.IllegalArgumentException: AppIndex: The URI host must match the package name and follow th

2016-03-30 19:21 706 查看
最近开始使用android studio进行开发,开发过程中突然出现一个很奇怪的问题,编译总是失败,后来发现工程引用的一个包里面的Androidmanifest.xml里多了几行这样的代码:
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
 App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
另外,该包里面的某个Activity也多了些代码:
<pre name="code" class="java"><pre name="code" class="javascript"><pre name="code" class="java">@Overridepublic void onStart() {super.onStart();// ATTENTION: This was auto-generated to implement the App Indexing API.// See https://g.co/AppIndexing/AndroidStudio for more information.client.connect();Action viewAction = Action.newAction(Action.TYPE_VIEW, // TODO: choose an action type."McldActivityBoxVideo Page", // TODO: Define a title for the content shown.// TODO: If you have web page content that matches this app activity's content,// make sure this auto-generated web page URL is correct.// Otherwise, set the URL to null.Uri.parse("http://host/path"),// TODO: Make sure this auto-generated app deep link URI is correct.Uri.parse("android-app://com.mining.cloud/http/host/path"));AppIndex.AppIndexApi.start(client, viewAction);}
<pre name="code" class="java"> @Overridepublic void onStop() {super.onStop();// ATTENTION: This was auto-generated to implement the App Indexing API.// See https://g.co/AppIndexing/AndroidStudio for more information.Action viewAction = Action.newAction(Action.TYPE_VIEW, // TODO: choose an action type."McldActivityBoxVideo Page", // TODO: Define a title for the content shown.// TODO: If you have web page content that matches this app activity's content,// make sure this auto-generated web page URL is correct.// Otherwise, set the URL to null.Uri.parse("http://host/path"),// TODO: Make sure this auto-generated app deep link URI is correct.Uri.parse("android-app://com.mining.cloud/http/host/path"));AppIndex.AppIndexApi.end(client, viewAction);client.disconnect();}
删掉Androidmanifest.xml中的自动生成的代码,工程可以跑起来,但是进入上面那个Activity时出现异常退出程序:
<pre name="code" class="java">java.lang.IllegalArgumentException: AppIndex: The URI host must match the package name and follow the format (android-app://<package_name>/<scheme>/[host_path]). Provided URI: android-app://com.mining.cloud/http/host/patjava.lang.RuntimeException: Unable to start activity ComponentInfo{com.vimtag.vimtaga/com.mining.cloud.McldActivityTabVideo}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vimtag.vimtaga/com.mining.cloud.McldActivityBoxVideo}: java.lang.IllegalArgumentException: AppIndex: The URI host must match the package name and follow the format (android-app://<package_name>/<scheme>/[host_path]). Provided URI: android-app://com.mining.cloud/http/host/pathat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)at android.app.ActivityThread.access$800(ActivityThread.java:142)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)at android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:136)at android.app.ActivityThread.main(ActivityThread.java:5217)at java.lang.reflect.Method.invokeNative(Native Method)at java.lang.reflect.Method.invoke(Method.java:515)at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)at dalvik.system.NativeStart.main(Native Method)Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vimtag.vimtaga/com.mining.cloud.McldActivityBoxVideo}: java.lang.IllegalArgumentException: AppIndex: The URI host must match the package name and follow the format (android-app://<package_name>/<scheme>/[host_path]). Provided URI: android-app://com.mining.cloud/http/host/pathat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)at android.app.ActivityThread.startActivityNow(ActivityThread.java:2041)at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)at android.widget.TabHost.setCurrentTab(TabHost.java:413)at android.widget.TabHost.addTab(TabHost.java:240)at com.mining.cloud.McldActivityTabVideo.init(McldActivityTabVideo.java:223)at com.mining.cloud.McldActivityTabVideo.onCreate(McldActivityTabVideo.java:61)at android.app.Activity.performCreate(Activity.java:5303)at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1091)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255) at android.app.ActivityThread.access$800(ActivityThread.java:142) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5217) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:818) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634) at dalvik.system.NativeStart.main(Native Method) 
然后,把这个Activity中系统自动生成的代码删除,恢复正常!

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: