2017-01-26 8 views
0
Gradle 2.14 

android { 
    dev { 
    } 
} 

    task runAppDev(type: Exec, dependsOn: 'installDev') { 
     description "Install and run app (dev env)" 
     android.applicationVariants.all { variant -> 
      if ("installDev".toUpperCase().endsWith(variant.getName().toUpperCase())) { 
       commandLine getRunAppCommandLine(variant) 
      } 
     } 
    } 

    def getRunAppCommandLine(variant) { 
     List<String> commandLine = ["adb", "shell", "am", "start", "-n", variant.getApplicationId() + "/.activity.SplashActivity"] 
     return commandLine 
    } 

はで私のタスクを実行します。gradlew runAppDevgradleタスクでデバイスにAndroidアプリをインストールして実行するにはどうすればよいですか?

結果:

は 'ネクサス5 - 6.0.1' にAPK 'アプリ-dev.apk' をインストールするアプリのために: がインストールdevの1デバイス。 :アプリ:

SUCCESSFUL runAppDev BUILDだから、私のアプリケーションの成功は、デバイスにインストールではなく、デバイス上で実行します。

答えて

0

バグが見つかりました。私は間違ったadb argを送る。ここで修正する:

def getRunAppCommandLine(variant) { 
    List<String> commandLine = ["adb", "shell", "monkey", "-p", variant.getApplicationId() + " 1"] 
    return commandLine 
} 
関連する問題