android-maven-plugin debug一直在等待调试器

时间:2016-04-05 07:52:58

标签: java android maven debugging

我正在使用android-maven-plugin,当我尝试调试代码时,希望它在断点处停止,它一直在等待调试器.... 我没有做过任何特别的工作。

我的POM:

<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>es.mycode.sgcv</groupId>
<artifactId>sgcv-android</artifactId>
<version>3.0.0</version>
<packaging>apk</packaging>
<name>sgcv-android</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <platform.version> 4.1.1.4</platform.version>
    <android.plugin.version>4.0.0-rc.2</android.plugin.version>
    <android.home>${env.ANDROID_HOME}</android.home>
    <android.sdk.path>${env.ANDROID_HOME}</android.sdk.path>
    <android.version>4.2.2_r3</android.version>
<android.platform>17</android.platform>
</properties>
<repositories>
    <repository>
        <id>android-support</id>
        <url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
    </repository>
</repositories>
<dependencies>
<dependency>
 <groupId>android</groupId>
 <artifactId>android</artifactId>
 <version>${android.version}</version>
 <scope>provided</scope>
</dependency>

    <dependency>
        <groupId>de.mindpipe.android</groupId>
        <artifactId>android-logging-log4j</artifactId>
        <version>1.0.3</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- Dependencias para trazas -->
    <dependency>
        <groupId>com.loopj.android</groupId>
        <artifactId>android-async-http</artifactId>
        <version>1.4.4</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>com.j256.ormlite</groupId>
        <artifactId>ormlite-android</artifactId>
        <version>4.46</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>

    <dependency>
        <groupId>org.osmdroid</groupId>
        <artifactId>osmdroid-android</artifactId>
        <version>4.2</version>
    </dependency>
    <dependency>
        <groupId>org.osmdroid.bonuspack</groupId>
        <artifactId>osmbonuspack</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>de.grundid.opendatalab</groupId>
        <artifactId>geojson-jackson</artifactId>
        <version>1.6-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-android</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>support-v4</artifactId>
        <version>23.0.1</version>
        <type>aar</type>
    </dependency>
    <dependency>
        <groupId>com.android.support</groupId>
        <artifactId>appcompat-v7</artifactId>
        <version>23.0.1</version>
        <type>aar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>support-v4</artifactId>
                <groupId>com.android.support</groupId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
  <plugin>
    <groupId>com.simpligility.maven.plugins</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>4.3.0</version> <!-- use latest release -->
    <extensions>true</extensions>
                    <configuration>
                <fork>false</fork>
                <release>false</release>
                <includeLibsJarsFromAar>true</includeLibsJarsFromAar>
                <resourceDirectory>${basedir}/res</resourceDirectory>
                <assetsDirectory>${basedir}/assets</assetsDirectory>
                <androidManifestFile>${basedir}/AndroidManifest.xml</androidManifestFile>
                <nativeLibrariesDirectory>${basedir}/libs</nativeLibrariesDirectory>
                <run>
                    <debug>false</debug>
                </run>
                <sdk>
                    <platform>23</platform>
                </sdk>
            </configuration>
  </plugin>

    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>com.simpligility.maven.plugins</groupId>
                                    <artifactId>android-maven-plugin</artifactId>
                                    <versionRange>[4.3.0,)</versionRange>
                                    <goals>
                                        <goal>emma</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

我使用此目标运行应用程序:

-Dandroid.run.debug = true android:run

有人有任何建议吗?

非常感谢您提前

1 个答案:

答案 0 :(得分:1)

我也没有弄清楚这应该如何与Android调试选项一起使用,但我能够手动启动调试器(我假设你的设备有调试选项可用):

  • 在您的设备上部署应用程序,就像使用Maven一样使用无调试选项并启动它(clean install android:deploy android:run)。
  • 现在切换到DDMS视图(我仍然使用Eclipse而不是Android工作室,所以也许它在Android Studio中不一样)
  • 在DDMS视图中的设备标识符下,您会看到应用的包名称。除此之外还有数字。第二个数字是您必须连接的端口。
  • 创建调试配置Remote Java Application。项目名称是根项目,主机是localhost,端口是DDMS的给定端口,在我的情况下它是8600。连接类型为Socket Attach
  • 现在单击debug并在代码中的任何位置设置断点。调试器将停在那里。