Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven build android project: specify the location of aidl file

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?

like image 964
user842225 Avatar asked Jul 02 '15 07:07

user842225


People also ask

Where do I put AIDL files?

Simply save your . aidl file in your project's src/ directory and when you build your application, the SDK tools generate the IBinder interface file in your project's gen/ directory.


2 Answers

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

like image 100
AnswerDroid Avatar answered Oct 29 '22 14:10

AnswerDroid


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.

like image 24
xxxzhi Avatar answered Oct 29 '22 15:10

xxxzhi