2016-09-17 1 views
9

나는 free와 pro (버전)이라는 두 가지 맛을 지닌 하나의 프로젝트를 만들려고하고있다.맛을 서로 다른 패키지 이름을 사용하는 방법은 무엇입니까?

내 응용 프로그램이 다른 패키지와 PLAYSTORE 이미 (예 : com.example.appfree 및 com.example.app)

이 내 build.gradle입니다 :

defaultConfig { 
    applicationId "com.example.appfree" 
} 
productFlavors{ 
    lite { 
     applicationIdSuffix 'lite' 
    } 

    pro { 

    } 
} 

그리고 이것은 내입니다 매니페스트 파일 :

<?xml version="1.0" encoding="utf-8"?> 
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.app"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 

     <activity 
      android:name=".SplashScreenActivity" 
      android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity android:name=".MainActivity"/> 

    </application> 

</manifest> 

무료 및 프로 프리어 용 빌드 apk를 업로드하려고했습니다. 프로의 맛은 괜찮지 만, 패키지가 올바르지 않기 때문에 Google에서 무료 맛을 인정하지 않습니다. 이 문제를 어떻게 해결할 수 있습니까?

====== 해결 : ====== applicationIdSuffix는 buildTypes에서만 작동합니다.

+4

Android Studio Project Site - ApplicationId versus PackageName에서 나는 applicationIdSuffix'이 맛을 위해 일'알고하지 않았다. 'applicationId'를 사용하여 향미료에 사용하려는 정확한 애플리케이션 ID를 입력하십시오. – CommonsWare

+0

@CommonsWare, 좋은 답변입니다! applicationIdSuffix는 buildTypes에서만 작동합니다! 나는 applicationId를 사용했으며 완벽하게 작동합니다! :) –

답변

9

새로운 Android Gradle 빌드 시스템을 사용하면 여러 버전의 앱을 쉽게 빌드 할 수 있습니다. 예를 들어 맛을 사용하여 앱의 '무료'버전과 '프로'버전을 모두 만들 수 있으며 Google Play 스토어에 패키지가 있어야 각기 다른 방식으로 설치하거나 구매할 수 있습니다 (둘 다에 설치됨). 같은 시간 등등. 마찬가지로 빌드 유형을 사용하여 앱의 "디버그"및 "알파"및 "베타"버전을 빌드 할 수도 있으며, 이는 고유 한 패키지 이름에도 유사하게 기여할 수 있습니다.

응용 프로그램/build.gradle :

apply plugin: 'com.android.application' 
android { 
    compileSdkVersion 19 
    buildToolsVersion "19.1" 
    defaultConfig { 
     applicationId "com.example.my.app" 
     minSdkVersion 15 
     targetSdkVersion 19 
     versionCode 1 
     versionName "1.0" 
    } 
... 

응용 프로그램/build.gradle :

productFlavors { 
    pro { 
     applicationId = "com.example.my.pkg.pro" 
    } 
    free { 
     applicationId = "com.example.my.pkg.free" 
    } 
} 

buildTypes { 
    debug { 
     applicationIdSuffix ".debug" 
    } 
} 
.... 

+0

당신은 내 질문에 대답하지 않았다 : 나는 무료 및 프로 맛을 위해 빌드 APK를 업로드하려했다. 프로의 맛은 괜찮지 만, 패키지가 올바르지 않기 때문에 Google에서 무료 맛을 인정하지 않습니다. 이 문제를 어떻게 해결할 수 있습니까? –

+1

그는 당신에게 그것을 어떻게 할 것인가를 보여주었습니다. 단지 풍미 정의에서 앱에 적합한 패키지 이름을 사용해야 만합니다. – nasch