세상사는 이야기 / 도움이 되었다면 배너 클릭 부탁드려요~ →→→

2019년 1월 29일 화요일

[Unity Android] Unity 2018 - mainTemplate.gradle 정리

[Unity Android] 버전 체크 mainTemplate.gradle 파일

Unity 2018.3 버전에서 사용

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
    repositories {
        if (GradleVersion.current() >= GradleVersion.version("4.2")) {
            jcenter()
            google()
        } else {
            jcenter()
        }
        maven { url "https://maven.google.com/"}
    }


    dependencies {
           // use newer version of the plugin for newer unity/gradle versions
            if (GradleVersion.current() < GradleVersion.version("4.0")) {
                classpath 'com.android.tools.build:gradle:2.1.0'
            } else if (GradleVersion.current() < GradleVersion.version("4.2")) { // Unity 2018.1 : Gradle version 4.0.1
            classpath 'com.android.tools.build:gradle:2.3.3'
            } else {                        // Unity 2018.2 : Gradle version 4.2.1
                classpath 'com.android.tools.build:gradle:3.0.1'
            }
    }
}


allprojects {
    repositories {
        if (GradleVersion.current() >= GradleVersion.version("4.2")) {
            jcenter()
            google()
        } else {
            jcenter()
        }


        maven { url 'https://maven.google.com'}
        flatDir {
            dirs 'libs'
        }
    }
}


apply plugin: 'com.android.application'


dependencies {
    compile 'com.android.support:multidex:1.0.1'


    if (GradleVersion.current() >= GradleVersion.version("4.2")) {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    } else {
        compile fileTree(dir: 'libs', include: ['*.jar'])
    }
**DEPS**
}


android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'


    if (GradleVersion.current() < GradleVersion.version("4.2")) {
        // fix complaint that 3rd party libraries have the same package name
        enforceUniquePackageName false
    }


    defaultConfig {
        minSdkVersion    **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        applicationId '**APPLICATIONID**'
        
        versionCode    **VERSIONCODE**
        versionName    '**VERSIONNAME**'


        // Enabling multidex support.
        multiDexEnabled true


        if (GradleVersion.current() >= GradleVersion.version("4.0")) {
            ndk {
                abiFilters **ABIFILTERS**
            }
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }


    lintOptions {
        abortOnError false
    }


    aaptOptions {
        noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
    }


**SIGN**
    buildTypes {
          debug {
             minifyEnabled **MINIFY_DEBUG**
            if (GradleVersion.current() >= GradleVersion.version("4.2")) {// > Build-in class shrinker and multidex are not supported yet.
                useProguard **PROGUARD_DEBUG**            
            }
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              jniDebuggable true
          }
          release {
             minifyEnabled **MINIFY_RELEASE**
             if (GradleVersion.current() >= GradleVersion.version("4.2")) {// > Build-in class shrinker and multidex are not supported yet.
                useProguard **PROGUARD_RELEASE**
            }
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
              **SIGNCONFIG**
          }
    }
**PACKAGING_OPTIONS**
}


**SOURCE_BUILD_SETUP**


2019년 1월 3일 목요일

[Unity Android] Admob - The Google Mobile Ads SDK was initialized incorrectly.

[Unity Android] Admob - The Google Mobile Ads SDK was initialized incorrectly.

Unity Admob SDK 추가 후 에러 발생
AdMob AppID를 설정하지 않아서 발생하는 에러로 AndroidManifest.xml파일에 AppID 추가 하면 된다.

아래 에러에 나와있는 링크를 보면 해당 설명을 따라하면된다.
https://goo.gl/fQ2neu




GoogleMoblieAdsPlugin 폴더 AndroidManifest.xml파일 AppID 추가

Assets/Plugins/Android/GoogleMobileAdsPlugin/AndroidManifest.xml
  • APPLICATION_ID 추가
<?xml version="1.0" encoding="utf-8"?>
<!--
This Google Mobile Ads plugin library manifest will get merged with your
application's manifest, adding the necessary activity and permissions
required for displaying ads.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.unity.ads"
    android:versionName="1.0"
    android:versionCode="1">
  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
  <application>
    <!-- Your AdMob App ID will look similar to this sample ID: ca-app-pub-3940256099942544~3347511713 -->
    <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713"/>
  </application>
</manifest>


2019년 1월 2일 수요일

[Android] IAP Subscription Google 영수증 정보

[Android] IAP Subscription Google 영수증 정보

UnityIAP 구독 처리 진행 Google 영수증 정보
https://docs.unity3d.com/kr/2017.4/Manual/UnityIAPPurchaseReceipts.html
https://developer.android.com/google/play/billing/billing_reference.html

로그인 시 "IAP 구독 상품"이 있는지 확인을 위한 "구독 영수증 정보"를 정리했다.
구글에서는 "IAP 구독 테스트"를 위해 기간에 상관없이 5분에 한번씩 결제가 되어서 빠르게 영수증 정보가 확인 가능하다.(자동으로 5번까지 결제됨)

1. 구독 첫 결제
autoRenewing = true
GPA.1234-1234-1234-12345 -
{
    "Store":"GooglePlay",
    "TransactionID":"GPA.1234-1234-1234-12345",
    "Payload":"
    {
        \"json\":\"
        {
            \\\"orderId\\\":\\\"GPA.1234-1234-1234-12345\\\",
            \\\"packageName\\\":\\\"com.kor.fms\\\",
            \\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
            \\\"purchaseTime\\\":1545900055028,
            \\\"purchaseState\\\":0,
            \\\"developerPayload\\\":\\\"
            {
                \\\\\\\"developerPayload\\\\\\\":\\\\\\\"asdfokjdfsafOTI0N3M2RljEz\\\\\\\\n\\\\\\\",
                \\\\\\\"is_free_trial\\\\\\\":false,
                \\\\\\\"has_introductory_price_trial\\\\\\\":false,
                \\\\\\\"is_updated\\\\\\\":false
            }
            \\\",
            \\\"purchaseToken\\\":\\\"maddfaddkoodicpdkdclfpdf.AO-Rl-PBiB3myqbdk4zyWht_DFdfdfWyNVNmutQXSAD\\\",
            \\\"autoRenewing\\\":true
        }\",
        \"signature\":\"5t7anjvTKxP9zOIpqWqqS2A5n\y......wcQlJywnpE4yb8VtGZAsiWkFB06BF5EMA==\",
        \"skuDetails\":\"
        {
            \\\"productId\\\":\\\"com.kor.kor.subsoldierpack\\\",
            \\\"type\\\":\\\"subs\\\",
            \\\"price\\\":\\\"₩3,900\\\",
            \\\"price_amount_micros\\\":3900000000,
            \\\"price_currency_code\\\":\\\"KRW\\\",
            \\\"subscriptionPeriod\\\":\\\"P1W\\\",
            \\\"title\\\":\\\"Soldier Pack(7days)\\\",
            \\\"description\\\":\\\"300 Gems immediately.\\\\nAnd more during the subscription period.\\\"
        }\",
        \"isPurchaseHistorySupported\":true
    }"
}


1-1. 구독 정보 확인
GPA.1234-1234-1234-12345 -
{
"Store":"GooglePlay",
"TransactionID":"GPA.1234-1234-1234-12345",
"Payload":"
{
\"json\":\"
{
\\\"orderId\\\":\\\"GPA.1234-1234-1234-12345\\\",
\\\"packageName\\\":\\\"com.kor.fms\\\",
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"purchaseTime\\\":1545964510849,
\\\"purchaseState\\\":0,
\\\"developerPayload\\\":\\\"
{
\\\\\\\"developerPayload\\\\\\\":\\\\\\\"asdfokjdfsafOTI0N3M2RljEz\\\\\\\\n\\\\\\\",
\\\\\\\"is_free_trial\\\\\\\":false,
\\\\\\\"has_introductory_price_trial\\\\\\\":false,
\\\\\\\"is_updated\\\\\\\":false
}\\\",
\\\"purchaseToken\\\":\\\"maddfaddkoodicpdkdclfpdf.AO-Rl-PBiB3myqbdk4zyWht_DFdfdfWyNVNmutQXSAD\\\",
\\\"autoRenewing\\\":true
}\",
\"signature\":\"k4naFJ4RxZV7qC33U7D7Q74ouevyhLTXG\\/Rk+\\/BAkPsfwDy8AvJwneEpVgvt05HVqd0N8CwCV4xJEF7if\\/==\",
\"skuDetails\":\"
{
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"type\\\":\\\"subs\\\",
\\\"price\\\":\\\"₩3,900\\\",
\\\"price_amount_micros\\\":3900000000,
\\\"price_currency_code\\\":\\\"KRW\\\",
\\\"subscriptionPeriod\\\":\\\"P1W\\\",
\\\"title\\\":\\\"My Soldier Pack(7days) (MY GAME)\\\",
\\\"description\\\":\\\"300 Gems immediately.\\\\nAnd more during the subscription period.\\\"
}\",
\"isPurchaseHistorySupported\":true
}"
}


2. 구독 두번째 결제 
autoRenewing = true

구독 정보 receipt
GPA.1234-1234-1234-12345 -
{
"Store":"GooglePlay",
"TransactionID":"GPA.1234-1234-1234-12345",
"Payload":"
{
\"json\":\"
{
\\\"orderId\\\":\\\"GPA.1234-1234-1234-12345\\\",
\\\"packageName\\\":\\\"com.kor.fms\\\",
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"purchaseTime\\\":1545964510849,\\\"purchaseState\\\":0,
\\\"developerPayload\\\":\\\"
{
\\\\\\\"developerPayload\\\\\\\":\\\\\\\"asdfokjdfsafOTI0N3M2RljEz\\\\\\\\n\\\\\\\",\
\\\\\\"is_free_trial\\\\\\\":false,
\\\\\\\"has_introductory_price_trial\\\\\\\":false,
\\\\\\\"is_updated\\\\\\\":false
}\\\",
\\\"purchaseToken\\\":\\\"maddfaddkoodicpdkdclfpdf.AO-Rl-PBiB3myqbdk4zyWht_DFdfdfWyNVNmutQXSAD\\\",
\\\"autoRenewing\\\":true
}\",
\"signature\":\"k4naFJ4RxZV7qC33U7D7Q74ouevyhLTXG\\/Rk+\\//BAkPsfwDy8AvJwneEpVgvt05HVqd0N8CwCV4xJEF7if\\/==\",
\"skuDetails\":\"
{
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"type\\\":\\\"subs\\\",
\\\"price\\\":\\\"₩3,900\\\",
\\\"price_amount_micros\\\":3900000000,
\\\"price_currency_code\\\":\\\"KRW\\\",
\\\"subscriptionPeriod\\\":\\\"P1W\\\",
\\\"title\\\":\\\"My Soldier Pack(7days) (MY GAME)\\\",
\\\"description\\\":\\\"300 Gems immediately.\\\\nAnd more during the subscription period.\\\"
}\",
\"isPurchaseHistorySupported\":true
}"
}

3. 구독 취소
autoRenewing = false
signature값이 변경되서 온다

구독 정보 receipt
GPA.1234-1234-1234-12345 - 
{
"Store":"GooglePlay",
"TransactionID":"GPA.1234-1234-1234-12345",
"Payload":"
{
\"json\":\"
{
\\\"orderId\\\":\\\"GPA.1234-1234-1234-12345\\\",
\\\"packageName\\\":\\\"com.kor.fms\\\",
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"purchaseTime\\\":1545964510849,\\\"purchaseState\\\":0,
\\\"developerPayload\\\":\\\"
{
\\\\\\\"developerPayload\\\\\\\":\\\\\\\"asdfokjdfsafOTI0N3M2RljEz\\\\\\\\n\\\\\\\",
\\\\\\\"is_free_trial\\\\\\\":false,
\\\\\\\"has_introductory_price_trial\\\\\\\":false,
\\\\\\\"is_updated\\\\\\\":false}\\\",
\\\"purchaseToken\\\":\\\"maddfaddkoodicpdkdclfpdf.AO-Rl-PBiB3myqbdk4zyWht_DFdfdfWyNVNmutQXSAD\\\",
\\\"autoRenewing\\\":false
}\",
\"signature\":\"qUCNlHNY6TJHZxVMTiaPPO6Fuis\\/De\\//+EJl7G0\\/uolQ\\//E5i5qm5rJFbG60\\/FqqWlbXAgLoeEIzA==\",
\"skuDetails\":\"
{
\\\"productId\\\":\\\"com.kor.fms.mysoldierpack\\\",
\\\"type\\\":\\\"subs\\\",
\\\"price\\\":\\\"₩3,900\\\",
\\\"price_amount_micros\\\":3900000000,
\\\"price_currency_code\\\":\\\"KRW\\\",
\\\"subscriptionPeriod\\\":\\\"P1W\\\",
\\\"title\\\":\\\"My Soldier Pack(7days) (MY GAME)\\\",
\\\"description\\\":\\\"300 Gems immediately.\\\\nAnd more during the subscription period.\\\"
}\",
\"isPurchaseHistorySupported\":true
}"
}

4. 구독 끝 
아무 정보도 오지 않는다.

 구독 정보 receipt
""