Building Android-Projekt in Maven: das Paket * nicht vorhanden
Baue ich meine app mit diesem Maven-Skript. Dann bekomme ich aber eine ganze Reihe von Fehlern (siehe am Ende des Postings). Es ist, als wenn android.jar wird nicht gefunden. Ich überprüfte den Pfad zu android.jar und es ist in Ordnung.
<?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>my.group.id</groupId>
<artifactId>myproject1.0</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>MyProject</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>maven-android-plugin</artifactId>
<version>2.6.0</version>
<configuration>
<sdk>
<platform>4</platform>
</sdk>
<emulator>
<avd>16</avd>
</emulator>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
Fehler:
C:\projectX>mvn install -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [android:generate-sources {execution: default-generate-sources}]
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Copying local resource files to combined resource directory.
[INFO] C:\dev\android-sdk-windows\platforms\android-4/tools/aapt [package, -m, -J, \
C:\projectX\target\generated-sources\r, -M, C:\projectX\AndroidManifest.xml, -S, \
C:\projectX\target\generated-sources\combined-resources\res,-A, C:\projectX\assets, -I, \
C:\dev\android-sdk-windows\platforms\android-4\android.jar]
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
C:\projectX\src\com\projectx\MyClass.java:[13,22] package org.apache.http does not exist
C:\projectX\src\com\projectx\MyClass.java:[23,29] package org.apache.http.entity does not exist
C:\projectX\src\com\projectx\MyClass.java:[28,29] package org.apache.http.params does not exist
C:\projectX\src\com\projectx\MyClass.java:[30,22] package android.content does not exist
C:\projectX\src\com\projectx\MyClass.java:[31,19] package android.util does not exist
C:\projectX\src\com\projectx\MyClass.java:[50,9] cannot find symbol
symbol : class DefaultHttpClient
location: class com.projectx.MyClass
C:\projectX\src\com\projectx\MyService.java:[10,24] package android.telephony does not exist
C:\projectX\src\com\projectx\MyService.java:[13,18] package android.app does not exist
C:\projectX\src\com\projectx\MyService.java:[19,22] package android.content does not exist
C:\projectX\src\com\projectx\MyService.java:[23,40] package android.content.SharedPreferences does not exist
C:\projectX\src\com\projectx\MyService.java:[25,18] package android.net does not exist
C:\projectX\src\com\projectx\MyService.java:[28,17] package android.os does not exist
C:\projectX\src\com\projectx\MyService.java:[29,25] package android.preference does not exist
C:\projectX\src\com\projectx\MyService.java:[30,19] package android.util does not exist
C:\projectX\src\com\projectx\MyService.java:[31,19] package android.view does not exist
C:\projectX\src\com\projectx\MyService.java:[34,21] package android.widget does not exist
C:\projectX\src\com\projectx\MyService.java:[54,36] cannot find symbol
symbol: class Service
public class MyService extends Service {
C:\projectX\src\com\projectx\MyClass.java:[103,34] cannot find symbol
symbol : class Context
location: class com.projectx.MyClass
C:\projectX\src\com\projectx\MyClass.java:[209,46] cannot find symbol
symbol : class Context
location: class com.projectx.MyClass
C:\projectX\src\com\projectx\MyClass.java:[229,37] cannot find symbol
symbol : class Context
location: class com.projectx.MyClass
C:\projectX\src\com\projectx\MyService.java:[75,16] cannot find symbol
symbol : class PendingIntent
location: class com.projectx.MyService
...truncated...
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
HINWEIS: ich habe die <verbose> in das maven-compiler-plugin und es funktioniert nicht android.jar in seinen classpath! Wie kann das überhaupt funktionieren? Nirgendwo in der Dokumentation heißt es ich muss noch etwas hinzufügen zum classpath.
InformationsquelleAutor Emmanuel | 2010-11-16
Du musst angemeldet sein, um einen Kommentar abzugeben.
Das problem war einfach, dass die
<dependencyManagement>
tag soll nicht da sein.InformationsquelleAutor Emmanuel
diese Zeile: C:\dev\android-sdk-windows\platforms\android-4/tools/aapt
sind Sie sicher, dass die /'s die richtigen sind und dort gebraucht? thatmight Grund sein, warum der android.jar wurde nicht abgeholt..
InformationsquelleAutor Fred Grott
Kann ich nicht reproduzieren, dein Fehler. Aber es scheint mir komisch, dass Sie die android.jar für 2.1.2 (gleis 7) und geben Sie die Plattform 4 (Android 1.6). Wenn Sie möchten, dass Ihre app ausführen, auf 1.6 solltest du verwenden android.jar von 1.6. wie dieses ist, was zur Laufzeit verfügbar.
Wenn Sie wollen Funktionen nutzen, die AndroidManifest.xml das kam bei gleis 8 (Froyo) wie installLocation sollten Sie nicht verwenden die Plattform 4, sondern 8 statt.
Wenn Sie mit Maven > Version 2.0.9 (IIRC), die Sie nicht haben, um geben Sie die version des plugins nicht mehr. Die neueste Version verwendet dann automatisch.
Ok, habe ich entfernt <version> in den <plugin - > es hat nicht darüber beklagen. Aber trotzdem bekomme ich die gleiche Fehlermeldung.
InformationsquelleAutor Dirk Jäckel