2016-04-28 78 views
5

我最近更新了我的Android Studio到版本2.1以及我正在研究Gradle版本2.1.0的项目。 我评论在我的代码线,无关与App索引代码是自动生成的,而现在,每当我尝试运行我的应用程序崩溃,并给了我以下错误:Android Studio - AppIndex URI

java.lang.RuntimeException: Unable to start activity ComponentInfo{lux.unisabana.sabanaviveenti/sabanaviveenti.unisabana.lux.unisabana.appsabana.MainActivity}: java.lang.IllegalArgumentException: AppIndex: The android-app URI host must match the package name and follow the format android-app://<package_name>/<scheme>/[host_path]. Provided URI: android-app://sabanaviveenti.unisabana.lux.unisabana.appsabana/http/host/path 

我到处寻找并尝试了很多东西,更新目标版本,所需的库以及目前为止没有任何工作,任何人都可以帮助我吗?

我使用编译的SDK是版本23和我使用谷歌服务的依赖是8.4.0

+0

你在你的URI主机中放了什么以及你的包名是什么? –

+0

正如我所说的,代码是自动生成的,但这里是那里的东西:'行动的viewAction = Action.newAction( \t \t \t \t Action.TYPE_VIEW, \t \t \t \t “主页”, \t \t \t \t// TODO:如果你有这个程序,活动的内容相匹配的网页内容, \t \t \t \t //确保这个自动生成的网页的URL是正确的 \t \t \t。//否则,将URL设置为null。 \t \t \t \t Uri.parse( “HTTP://主机/路径”), \t \t \t \t // TODO:确保此自动生成的应用程序的URL是正确的。 \t \t \t \t Uri.parse( “android-app://sabanaviveenti.unisabana.lux.unisabana.appsabana/http/host/path”) \t \t); \t \t AppIndex.AppIndexApi.start(client2,viewAction);' – Jpfcan

回答

3

我也一直在争取这个问题近两天。 简而言之:搜索“sabanaviveenti.unisabana.lux.unisabana.appsabana/http/host/path”的Java文件。您可能会在初始活动的OnStart()方法中找到它们。 您需要用包含主应用程序代码的软件包名称替换sabanaviveenti.unisabana.lux.unisabana.appsabana。例如。这样的事情:

Action viewAction=Action.newAction(
      Action.TYPE_VIEW, // TODO: choose an action type. 
      "LogTasks 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 URL is correct. 
      // was: Uri.parse("android-app://sabanaviveenti.unisabana.lux.unisabana.appsabana/path"), 
      Uri.parse("android-app://com.myserver.mypackage/http/host/path") 
    ); 
    AppIndex.AppIndexApi.start(client, viewAction); 

我有这个问题的原因是因为我重组应用程序的代码,同时更新Android Studio和SDK。不知怎的,这个代码是自动创建的。就我而言,活动位于库包中,但应用程序中的主要活动来自此活动,所以我没有直接看到原始活动代码。

+2

我刚刚删除了生成的代码,我不需要它。 –