Android Maven plugin - How to start an app automatically after deploying it

萝らか妹 提交于 2020-01-01 05:33:11

问题


I wondering if there's a way to start an application which was deployed using mvn install android:deploy automatically. If this is somehow possible it would speedup development.


回答1:


Here the post: http://www.hrupin.com/2011/06/21/how-to-run-android-application-then-you-use-maven-in-your-project

First you need to add plugin in your POM

<plugin>
    <artifactId>exec-maven-plugin</artifactId>
    <groupId>org.codehaus.mojo</groupId>
    <configuration>
            <executable>${basedir}/scripts/run_app.sh</executable>
    </configuration>
</plugin>

add script in ${basedir}/scripts/ dir with next content:

adb shell am start -a android.intent.action.MAIN -n your.app.package/.YourMainActivity

Command to build and run app

mvn clean install android:deploy; mvn exec:exec




回答2:


Since maven-android-plugin version 3.0.0, you can use:

mvn install android:deploy android:run

and works perfectly.

Plugin's changelog here.



来源:https://stackoverflow.com/questions/7673227/android-maven-plugin-how-to-start-an-app-automatically-after-deploying-it

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