2016-08-23 2 views
0

동일한 앱을 설치하려고하지만 버전/변형이 다릅니다. 그래서 나는이 블로그를 발견했다. 내가 Gitbash에서gradle에 인수가 전달되었습니다. android

enter image description here

을 ':이 명령을 실행 한 후

apply plugin: 'com.android.application' 

def debugsuffix = System.getProperty('debugsuffix', project.getProperties().get('debugsuffix', null)) 

def final appId = 'com.arthlimchiu.testapp' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "24.0.0" 

    defaultConfig { 
     applicationId = appId 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    productFlavors { 
     dev { 
      applicationId = appId + "." + debugsuffix + ".dev" 
      resValue "string", "app_name", ".dev-" + debugsuffix 
     } 
    } 

    lintOptions { 
     abortOnError false 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
} 

: https://blog.grandcentrix.net/how-to-install-different-app-variants-on-one-android-device/ 나는 가 여기 내 Gradle을 파일의 다른 스프린트에 대해 서로 다른 애플 리케이션 블로그의 그림과 같은 무언가를하고 싶었다 Windows에서 btw, debugsuffix가 NULL입니다.

다음은 응용 프로그램 이름으로 debugsuffix를 표시하여 디버깅하려 한 스크린 샷입니다. enter image description here

나는 명령을 올바르게하고 있습니까? 또는 나는 무엇인가 놓치고 있냐? 인수를 통과하면서 이런 종류의 일을하는 것은 처음입니다. 아무도 이것을 시도한 적이 있습니까? 정말 큰 도움이 될 것입니다 :)

+0

어디에서 인수를 전달합니까? 빌드 오류가 발생합니까? 그렇다면 오류가 무엇입니까? –

+0

Windows 용 gradlew.bat가있을 때 왜 MinGW를 사용하고 있습니까? –

+0

내 gitbash의 스크린 샷을 보면 debugsuffix가 매개 변수이고 인수로 "bug44"를 전달했습니다. "debugsuffix"변수를 사용하여 내 응용 프로그램의 이름을 ".dev-null"로 표시하여 디버깅 한 결과로 빌드 오류가 발생하지 않았습니다. null 부분은 디버그 접미어입니다. 왜 그것이 null인지 나는 모른다. –

답변

0

마침내 했어요! 나는 실제로 Gradle이 제공 한 무료 전자 책을 읽었습니다. 그리고 하나의 기기에 여러 개의 동일한 앱을 설치하는 방법을 해결하는 방법에 대한 아이디어가 있습니다.

이것은 내 Gradle 파일입니다.

apply plugin: 'com.android.application' 

def debugsuffix = System.getProperty('debugsuffix', project.getProperties().get('debugsuffix', null)) 

def final appId = 'com.arthlimchiu.testapp' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "24.0.0" 

    defaultConfig { 
     applicationId = appId 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 

    buildTypes { 
     debug { 
      applicationIdSuffix ".$debugsuffix" 
      resValue "string", "app_name", "testApp-$debugsuffix" 
     } 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    lintOptions { 
     abortOnError false 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
} 

그리고 당신이 명령을 실행이 :

Make sure you use "-P" and it's first executed

당신은 당신의 명령 줄에서 체인 작업은 공백으로 구분 할 수 있습니다.

enter image description here

이제 -Sprint1 등 또는 [프로그램 응용] -bug - 수정 - 05 [프로그램 응용] 같은 작업을 수행 할 수 있습니다

그리고 여기에 출력합니다. 그런 것.

관련 문제