My android project has only aidl file, project structure is like below:
MyProject/
src/
main/
com.my.aidl/
IMyService.aidl
pom.xml
I am building my android project with maven. My pom uses the dexguard-maven-plugin which is an extension of android-maven-plugin.
In plugin configuration, I explicitly specified the directory of source aidl file & the directory of generated java file.
<build>
<plugins>
<plugin>
<groupId>com.saikoa.dexguard.maven</groupId>
<artifactId>dexguard-maven-plugin</artifactId>
<configuration>
<aidlSourceDirectory>
${project.basedir}/src/main/com/my/aidl
</aidlSourceDirectory>
<genDirectoryAidl>
${project.build.directory}/generated-sources/aidl/main/com/my/aidl
</genDirectoryAidl>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
But after I run mvn clean install -e I got the following error trace:
[ERROR] Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources (default-generate-sources) on project MyProject: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources (default-generate-sources) on project MyProject: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:334)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateAidlFiles(GenerateSourcesMojo.java:1266)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:343)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
What is wrong?
Had a similar issue few months ago where I was placing my call related aidl files to incorrect location (I migrated form Eclipse ANT to Studio Gradle).The link below helped in my case:how can I add the aidl file to Android studio (from the in-app billing example)And official document related to that:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure
Depend on your log message, there has a nullexception. I guess the directory is not right. Have you try to change the genDirectoryAidl from 'generated-sources/aidl/main/com/my/aidl' to 'generated-sources/aidl/'? Maybe if you make a directory named 'main/com/my/aidl' you will succeed.
Hope this message can help you.
As I can see is a NullPointerException possibly caused by some unresolved dependencies. Here is a link for similar issue.
Also try to re-run maven with -X and show us the debug output.
Related
I downloaded zxing and tried to build it locally with mvn.
I got some problem, when I try to build android project (to make it a jar other than apk file), I got this error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------ ------
[INFO] Building Android Barcode Scanner app 4.7.1
[INFO] ------------------------------------------------------------------ ------
[WARNING] The POM for com.google.zxing:core:jar:3.1.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.zxing:android-core:jar:3.1.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.352 s
[INFO] Finished at: 2015-01-27T13:32:25+00:00
[INFO] Final Memory: 10M/36M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project android: Could not resolve dependencies for project com.google.zxing:android:jar:4.7.1: The following artifacts could not be resolved: com.google.zxing:core:jar:3.1.1-SNAPSHOT, com.google.zxing:android-core:jar:3.1.1-SNAPSHOT: Failure to find com.google.zxing:core:jar:3.1.1-SNAPSHOT in https://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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]
I put android-core-3.1.1-SNAPSHOT.JAR AND core-3.1.1-SNAPSHOT.JAR into the libs folder of android project, but it doesn't help at all.
what I am doing wrong? The pom file under android folder is
<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>
<artifactId>android-core</artifactId>
<version>3.1.1-SNAPSHOT</version>
<packaging>jar</packaging>(i changed from apk to jar as I want to build it as a jar other than apk)
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>com.google.zxing</groupId>
<artifactId>zxing-parent</artifactId>
<version>3.1.1-SNAPSHOT</version>
</parent>
<name>ZXing Android Core</name>
<description>Code common to Android applications</description>
</project>
This is just a Maven question. You have downloaded source code for master, so points to SNAPSHOT builds. If you really want to use that, you need to mvn install to create snapshot artifacts locally. Here you just went straight to android/ and built it, but that won't work. Just build everything from the top level and it will work.
This is described at https://github.com/zxing/zxing/wiki/Getting-Started-Developing except that if you are building snapshots off master you need to mvn install not mvn package.
I've just downloaded Cordova, along with all the requirements for Android and Windows Phone. I can successfully build a WP8 image and send it to my 8X, however, I can't seem to be able to build an Android image.
When I execute cordova build android, I get the following error:
Generating config.xml from defaults for platform "android"
Preparing android project
Compiling app on platform "android" via command "cmd" /c Y:\mobile\platforms\android\cordova\build
C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while building the android project.
at ChildProcess.<anonymous> (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\src\compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
And when I launch the build command manually, I get the following error:
Error executing "ant debug -f "Y:\mobile\platforms\android\build.xml"":
BUILD FAILED
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:962: The following error occurred while executing this line:
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:973: The following error occurred while executing this line:
C:\Development\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:313: com.android.sdklib.build.ApkCreationException: Y:\mobile\platforms\android\bin\rs
Libs does not exist
at com.android.sdklib.build.ApkBuilder.getNativeFiles(ApkBuilder.java:742)
at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:303)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
It seems that the cordova-3.3.0.jar file doesn't get compiled, shouldn't it get compiled automatically? Is there anything I'm missing?
It can be an error with Ant. I had this error because I forgot to change the environment variable path.
The path I added was wrong (you need to specify this folder: "way\to\apache-ant-1.9.3\bin"). I just changed it and it works now.
(If it's not that, it can be an other path environment variable such as node, or your java sdk or android sdk)
Hope it can help someone.
I just deleted the whole Android project, recompiled the CordovaLibs and recompiled the Android project. Seems to have fixed it.
try commands
cordova platform rm android
cordova platform add android
cordova build android
i was trying to follow this tutorial:
http://www.gdgankara.org/2012/11/01/step-by-step-android-development-with-maven/
but after setting up the environment, and create a project, at the "run as\maven install" step i got this:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building tutorial 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) # tutorial ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.889s
[INFO] Finished at: Sat May 18 00:32:12 CEST 2013
[INFO] Final Memory: 8M/111M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project tutorial: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources failed: Could not find tool 'aapt'. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. -> [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/PluginExecutionException
I've tried lot of times, but with no luck.
I have Eclipse Juno on Windows7 64 bit, APK Tool installed and Maven 3.0.5.
It seems a well known problem for maven staff:
https://code.google.com/p/maven-android-plugin/issues/detail?id=104
but it should be solved from ages...
My Environment User variables:
M2_HOME=C:\Program Files\Java\apache-maven-3.0.5
ANDROID_HOME=C:\adt-bundle-windows-x86_64-20130514\sdk
My Environment System variable:
Path=......;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools;%ANDROID_HOME%\platforms;%M2_HOME%\bin;%ANDROID_HOME%\build-tools\android-4.2.2
Does anybody know how to workout this trap?
thanks!
I also encountered the same problem when using latest ADT from google and trying to compile the bootstrap android platform.
The latest r17 build separate out aapt to build-tools folder. Hence it is maven-android-plugin cannot support it.
See issue discussed here.
Tried and working:
cd $ANDROID_HOME/platform-tools
ln -s ../build-tools/android-4.2.2/aapt aapt
ln -s ../build-tools/android-4.2.2/lib lib
ln -s ../build-tools/android-4.2.2/aidl aidl
Some installations may be structured using the API version:
cd $ANDROID_HOME/platform-tools
ln -s ../build-tools/17.0.0/aapt aapt
ln -s ../build-tools/17.0.0/lib lib
ln -s ../build-tools/17.0.0/aidl aidl
Keep in mind that this is fixed in the latest version (>3.5.3) of the Android Maven Plugin, as other answers point out.
Update:
This has been resolved since Android Maven Plugin v3.6.0. For now you will only need these symlinks if you use IntelliJ v12.x. IntelliJ v13 EAP+ should work out of the box.
Original answer:
This has been fixed and will be released with Android Maven Plugin v3.5.4. See the github pull request:
Upgraded AndroidSdk to use path and platform utilities from sdklib
You can try validating the snapshot build which contains the fix by adding the following to your pom.xml:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.4-SNAPSHOT</version>
...
</plugin>
...
<pluginRepositories>
<pluginRepository>
<id>oss.sonatype.org-jayway-snapshots</id>
<name>Jayway OpenSource SNAPSHOTs on Sonatype.org</name>
<url>http://oss.sonatype.org/content/repositories/jayway-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
Please provide feedback on the developer group:
New snapshot for 3.5.4 available
If you are using Windows, the symbolic linking can be done using mklink command.
D:\>cd "Program Files (x86)\Android\android-sdk"
D:\Program Files (x86)\Android\android-sdk>cd platform-tools
D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink aapt.exe ..\build-tools\17.0.0\aapt.exe
symbolic link created for aapt.exe <<===>> ..\build-tools\17.0.0\aapt.exe
D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink aidl.exe ..\build-tools\17.0.0\aidl.exe
symbolic link created for aidl.exe <<===>> ..\build-tools\17.0.0\aidl.exe
D:\Program Files (x86)\Android\android-sdk\platform-tools>mklink /d lib ..\build-tools\17.0.0\lib
symbolic link created for lib <<===>> ..\build-tools\17.0.0\lib
I get stuck with the same problem. Finally i managed to resolve the issue after two hours. To make it simple and resolve the issue in 5 minutes i listed the steps below
Step 1 - In Eclipse update your Android Maven Plugin to 0.4.3.2013 using the beta release link
http://rgladwell.github.io/m2e-android/updates/master/
Step 2
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
</configuration>
</plugin>
It will solve the following issues
"No Android Platform Version/API Level has been configured"
Could not find tool 'aapt'
Hope it helps
I too had similar problems.
Solved by following steps :
1) Upgrade maven to 3.1.1
2) Use android-maven-plugin 3.6.1 pr greater [I used 3.8.0]
3) Use maven-dependency-plugin 2.8
If you want to build against latest Android SDK [ex : 4.3], follow following additional steps -
4) Install the local copy of android.jar using command mvn install:installFile ..
5) Set 18
Hope this helps.
I'm using macOS 10.14 and in my case:
I download Android packaging tool from AAPT and then copied all the files into $ANDROID_HOME/platforms/$SDK/tools/
DON'T REMIND CHANGE $SDK WITH YOUR REAL NAME SDK FOR INSTANCE android-29
I am new to this maven concept, I am building one android application for which I am want to robospice lib. Rebospice demo example need maven clean install. I installed maven on my ubuntu 12.04
mvn -v
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_10, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-35-generic-pae", arch: "i386", family: "unix"
Then I tried maven clean install on my demo project it gives following error
[WARNING] The POM for com.octo.android.robospice:robospice:jar:1.3.2-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.351s
[INFO] Finished at: Mon Jan 21 15:15:55 IST 2013
[INFO] Final Memory: 10M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project robospice-sample-core: Could not resolve dependencies for project com.octo.android.robospice:robospice-sample-core:apk:1.0.0-SNAPSHOT: Could not find artifact com.octo.android.robospice:robospice:jar:1.3.2-SNAPSHOT -> [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/DependencyResolutionException.
Whats the problem behind this.. Need help to solve this problem....
You probably have to configure your maven repositories (You tell maven where to get the dependencies)
OR
Something went wrong the first time you tried to download the artefact.
If this is the later, you can solve the problem by browsing your ".m2" folder and go and see if the corresponding folder contains just metadata files or if it contains the jar and the pom as well. I something looks wrong, you can just delete the folder and retry to build your project.
By the way, it seems that this project "robospice" has a more recent version available (and stable, not snapshot), so you might want to try to use 1.3.1 instead of 1.0.0 SHAPSHOT, if it fits with your project needs.
I'm trying to build simple android project from Jenkins, but build fails with output message (verbose):
Building in workspace /var/lib/jenkins/jobs/MyProj/workspace
[MyProj] $ ant -file build.xml help -v
Apache Ant version 1.8.1 compiled on October 13 2010
Buildfile: /home/ramps/MyProj/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk/jre
Detected OS: Linux
parsing buildfile /home/ramps/MyProj/build.xml with URI = file:/home/ramps/MyProj/build.xml
Project base dir set to: /home/ramps/MyProj
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[property] Loading /home/ramps/MyProj/local.properties
[property] Loading /home/ramps/MyProj/ant.properties
Importing file /home/ramps/MyProj/custom_rules.xml from /home/ramps/MyProj/build.xml
Cannot find /home/ramps/MyProj/custom_rules.xml imported from /home/ramps/MyProj/build.xml
Importing file /usr/share/android-sdk-linux/tools/ant/build.xml from /home/ramps/MyProj/build.xml
BUILD FAILED
/home/ramps/MyProj/build.xml:81: Cannot find /usr/share/android-sdk-linux/tools/ant/build.xml imported from /home/ramps/MyProj/build.xml
at org.apache.tools.ant.taskdefs.ImportTask.importResource(ImportTask.java:181)
at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:162)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:179)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:82)
at org.apache.tools.ant.Main.runBuild(Main.java:786)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
MyProj is a clean project created via:
android create project --name MyProj --package com.myproj --target "android-15" --path MyProj --activity MyProj
of course file "/usr/share/android-sdk-linux/tools/ant/build.xml" exist.
"ant help" from shell runs fine.
local.properties contains valid path to android SDK:
sdk.dir=/usr/share/android-sdk-linux
Any idea why MyProj/build.xml cannot find "/usr/share/android-sdk-linux/tools/ant/build.xml" ?
Ok, I managed to solve it. User jenkins had no permission to enter android-sdk-linux folder.
In general, when debugging such issues it is very helpful to try to do manually what Jenkins is doing:
$sudo su jenkins
And now, as jenkins user try to enter folders, create new one etc.