0

根据 Lynda 的Up and Running with PhoneGap课程,我刚刚开始使用 eclipse 构建我的第一个 Android 项目。

当我尝试运行该项目(如Lynda上的演示)时,我收到以下错误消息:

“您的项目包含错误,请在运行您的应用程序之前修复它们。”

 Description Resource Path Location Type
 error: Error: No resource found that matches the given name (at 'label' with value 
              '@string/app_name').  AndroidManifest.xml /android_project    line 49
 Android AAPT Problem error: Error: No resource found that matches the given name (at 'label' 
 with value '@string/app_name').    AndroidManifest.xml /android_project line 52  Android
 AAPT Problem
 The import org.apache.cordova cannot be resolved   android_project.java  
 /android_project/src/com/example/android   line 23 Java Problem
 DroidGap cannot be resolved to a type  android_project.java    
 /android_project/src/com/example/android   line 25 Java Problem
 The method onCreate(Bundle) of type android_project must override or implement a supertype 
 method android_project.java    /android_project/src/com/example/android    line 28 Java   
 Problem DroidGap cannot be resolved to a type  android_project.java    
 android_project/src/com/example/android    line 30 Java Problem
 Config cannot be resolved  android_project.java    /android_project/src/com/example/android
 line 32    Java Problem

附上错误截图

错误示例

我可以猜到一些错误消息的含义,但我不知道如何解决它们。

有什么建议吗?

我正在使用 Windows 8。java 版本“1.7.0_25”Java(TM) SE 运行时环境(构建 1.7.0_25-b17)Java HotSpot(TM) 64 位服务器 VM(构建 23.25-b01,混合模式)

谢谢,里龙

4

2 回答 2

3

在你的项目>res>values 中检查你的strings.xml 并添加你将在你的项目中使用的字符串值。

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
    <string name="app_name">AppName</string>
</resources>

另外,我认为您需要更新您的 .jar 文件 cordova

您可以从phonegap github repo下载它。

您可以在 lib/android/ 文件夹中找到该库。

要创建一个新项目,您可以使用 lilb/andoird/bin/create.bat 文件。

不要忘记清理项目。

希望这对您有所帮助。

于 2013-06-27T09:15:47.190 回答
2

我想你忘了设置字符串值。我还没有读过那个教程,但是有一些字符串丢失了。检查教程,您必须在 res/values 文件夹中的 strings.xml 中设置一些字符串

编辑

转到您的项目“res/values”中的文件夹并打开strings.xml。然后开始一个新行并放

    <string name="example_string">This is an example!</string>  

第一部分“example_string”是字符串的名称。例如,这是在 xml 布局中引用它。想象一下,您在任何 xml 布局中都有一个按钮:

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/example_button"
        android:text="@string/example_string"/>  <-- here you refer to that string inside strings.xml

第二部分“这是一个示例”是该按钮上将显示的内容。

但我认为如果你学习基础知识而不是从 PhoneGap 开始会更好。

http://developer.android.com/training/basics/firstapp/index.html

于 2013-06-27T09:08:57.120 回答