由于无效的URI,安装失败。

3
[2013-07-21 11:14:01 - AndroidTrial] Installation failed due to invalid URI!
[2013-07-21 11:14:01 - AndroidTrial] Please check logcat output for more details.
[2013-07-21 11:14:02 - AndroidTrial] Launch canceled!  

当我尝试运行一个试验性项目时,出现了以下情况。Logcat中没有输出。
我查看了其他人在SO上针对类似问题的答案,他们说这可能是因为有重音字符。但是我没有遇到这种情况。
以下是我的简单代码:
public class HaikuDisplay extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void onTrialButtonClicked(View view){
        TextView v = (TextView) findViewById(R.id.text);
        v.setVisibility(View.VISIBLE);
    }

}  

这里是XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".HaikuDisplay" >
    <Button 
        android:id="@+id/topBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/love_button_text"
        android:onClick="onTrialButtonClicked"
        />
    <TextView
        android:layout_below="@id/topBtn"
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" 
        android:visibility="invisible"/>

</RelativeLayout>  

我该如何解决这个问题?

请查看此链接以获取与程序相关的内容:https://dev59.com/Zmkw5IYBdhLWcg3wGGq8#10182645 - Tarsem Singh
@Tarsem 我正在使用 Eclipse。 - An SO User
你尝试过清理项目吗? - Tarsem Singh
你是在设备上安装应用程序还是模拟器上? - Vikram
@vikram 模拟器。即使是由Eclipse生成的空白项目也会出现相同的错误。以前,它们运行得很好。 - An SO User
你应该重新启动Eclipse > 创建一个新的AVD > 尝试运行项目。如果可以的话,将应用程序在设备上运行以隔离问题。 - Vikram
3个回答

17

这个错误可能指向很多不同的问题,有许多种不同的解决方法。总结一下我收集到的:

  1. Eclipse的问题: 清除项目缓存、重建项目、重启eclipse。
  2. 无效字符: 删除Eclipse项目名称中的任何特殊字符。只使用[a-z]和[0-9],甚至没有[ ](空格)。
  3. 包含的jar包错误: 尝试不使用jar包运行并查看是否正常运行,如果是,请修复问题。
  4. 清单包设置错误: 在eclipse上右键单击项目 -> Android 工具 -> 重命名应用程序包(重命名为类似的名称,您可以随时重命名回来)。
  5. 设备问题: 从设备中删除应用并尝试重新安装。
  6. ROM问题: 如果您使用自定义ROM,请尝试刷入新的ROM。
  7. 未启用调试: 在手机上转到设置 -> 应用程序 -> 允许未知来源/启用调试(此路径对于不同的设备可能会有所不同)。

1
在我的情况下,问题出在 Android 项目名称中包含德语umlauts:äüö..。我重构了名称,然后它就可以工作了。

0
在我的情况下,是因为我已经更改了我的应用程序的strings.xml文件的名称:
<string name="app_name">My App</string>

卸载应用并重新安装解决了问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接