2016-04-28 80 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

我剛剛刪除了生成的代碼,我不需要它。 –