maven android error reading file source.properties

亡梦爱人 提交于 2020-02-05 07:06:15

问题


I am trying to build a simple hello world android app. I am getting this error:

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven- 
plugin:3.9.0-rc.2:generate-sources (default-generate-sources) on project ndbc: 
Execution default-generate-sources of goal 
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.9.0-rc.2:generate-
sources failed: Error reading /storage/code/android-NDBC/ndbc/~/android-sdks/tools
/source.properties -> [Help 1]

I am using maven 3.2.1

here is my POM:

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <finalName>ndbc</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.9.0-rc.2</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>19</platform>
                </sdk>
                                </configuration>
        </plugin>
    </plugins>
</build>

I believe that I have all my environment vars set correctly:

export ANDROID_SDK_HOME=/home/michel/android-sdks
export ANDROID_HOME=/home/michel/android-sdks
export PATH="$PATH:~/android-sdks/tools"
export PATH="$PATH:~/android-sdks/platform-tools"

when I run mvn install OR mvn android:apk I get the same error.

What is weird is that when I run this in eclipse I get the same error, but if I run it through the AVM it works fine, just actually BUILDING the apk that seems to be the problem.

Any ideas?


回答1:


Sasikumar M had the correct path.. (pun intended)

The android-maven-plugin is not picking up the ANDROID_HOME for some reason. Setting it in the properties did not work, but setting it in the plugin did. Set the path in the configuration. Here is POM fragment.

            <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <path>/home/michel/android-sdks</path>
                    <platform>19</platform>
                </sdk>
            </configuration>
        </plugin>



回答2:


I found that setting the path when running maven worked best for me, by adding the following: -Dandroid.sdk.path= before you call your targets



来源:https://stackoverflow.com/questions/24423624/maven-android-error-reading-file-source-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!