Android maven using wrong java version

梦想与她 提交于 2019-12-21 22:44:57

问题


I'm compiling my Android project against Android V2.2.1, I'm using an Android dependency:

<dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
</dependency>

Everything compiles fine and libraries that were introduced in later versions (Nfc related stuff for example) are not available and that's fine.

The problem arises when I'm using pure java methods like String.isEmpty which were introduced only in V2.3+, for some reason Maven doesn't fail with "cannot find symbol" but the compilation passes, it only fails on the device that runs version 2.2.

My android-maven-plugin conf:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.1.1</version>
    <configuration>
        <androidManifestFile>${project.basedir}/AndroidManifest.xml
        </androidManifestFile>
        <assetsDirectory>${project.basedir}/assets</assetsDirectory>
        <resourceDirectory>${project.basedir}/res</resourceDirectory>
        <nativeLibrariesDirectory>${project.basedir}/src/main/native
        </nativeLibrariesDirectory>
        <sdk>
            <platform>8</platform>
        </sdk>
        <undeployBeforeDeploy>true</undeployBeforeDeploy>
    </configuration>
    <extensions>true</extensions>

</plugin>

How can I make sure that the compile will fail ?


回答1:


You might want to try using the original android jar from the Sdk by deploying it to your repository or repository server using the Maven Android SDK Deployer. That might work.



来源:https://stackoverflow.com/questions/10363817/android-maven-using-wrong-java-version

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