近两天我一直在尝试使用 Fragments 构建一个 Android 应用程序,并且我正在使用 Maven。如果我尝试构建我的应用程序 Maven 会给出以下错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pontes Het Goese Lyceum 2.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.android:android:jar:2.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ pontes ---
[INFO] Deleting C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\target
[INFO]
[INFO] --- android-maven-plugin:3.3.0:generate-sources (default-generate-sources) @ pontes ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] C:\android-sdk-windows\platform-tools\aapt.exe [package, -m, -J, C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\target\generated-sources\r, -M, C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\AndroidManifest.xml, -S, C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\res, --auto-add-overlay, -A, C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\assets, -I, C:\android-sdk-windows\platforms\android-8\android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ pontes ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\src\main\resources
[INFO] skip non existing resourceDirectory C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\target\generated-sources\extracted-dependencies\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ pontes ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 11 source files to C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\src\com\koenv\pontes\RoosterFragment.java:[13,24] error: cannot access XmlPullParser
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.928s
[INFO] Finished at: Sat Aug 18 14:36:21 CEST 2012
[INFO] Final Memory: 13M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project pontes: Compilation failure
[ERROR] C:\Users\Koen\Android\Apps\Pontes Het Goese Lyceum\src\com\koenv\pontes\RoosterFragment.java:[13,24] error: cannot access XmlPullParser
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我正在使用以下 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.koenv</groupId>
<artifactId>pontes</artifactId>
<version>2.0</version>
<packaging>apk</packaging>
<name>Pontes Het Goese Lyceum</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>8</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
而检测到错误的文件只是一个简单的Fragment:
package com.koenv.pontes;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class RoosterFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.mijn_rooster, container, false);
}
}
我在做什么错,我在 Windows 上使用“maven clean install”。