maven android plugin:No Android SDK path could be found

后端 未结 4 820
臣服心动
臣服心动 2021-02-08 05:58

I use the maven-android-plugin version 3.3.2. When I try to build my android project I have the following exception:

org.apache.maven.p

4条回答
  •  眼角桃花
    2021-02-08 06:27

    From the documentation

    You may configure it in the android-maven-plugin configuration section in the pom.xml file using ... or ... or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME.

    Solution 1

    I have defined an Android SDK system variable called ANDROID_SDK (instead of ANDROID_HOME) and referenced it in my pom.xml this way:

      ...
      ...
      ...
      apk
      ...
      ...
    
      
        ${env.ANDROID_SDK}
        ...
      
    

    Solution 2

    As an alternative you can also configure it in the android-maven-plugin section:

    
    true
    com.jayway.maven.plugins.android.generation2
    android-maven-plugin
    ${android-maven-plugin.version}
    
      ${project.basedir}/AndroidManifest.xml
      ${project.basedir}/assets
      ${project.basedir}/res
      ${project.basedir}/src/main/native
      
        ${env.ANDROID_SDK}
        16
      
      true
    
    
    

    Solution 3

    As a third option you can set the SDK from the command line passing an argument to Maven:

    mvn clean install -Dandroid.sdk.path="C:\\Program Files (x86)\\Android\\android-sdk"

提交回复
热议问题