근본있는 블로그

화웨이 결제 구현(2) - 개발 세팅화웨이 결제 구현(2) - 개발 세팅 본문

Android

화웨이 결제 구현(2) - 개발 세팅화웨이 결제 구현(2) - 개발 세팅

ggbon 2021. 4. 12. 13:27
  • json 파일을 받아서 porject, app 디렉토리에 넣어준다.

 

  • build.gradle(Project) 에 다음을 추가
buildscript {
    repositories {
        google()
        jcenter()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        ...
        // Add AppGallery Connect plugin configurations.
        classpath 'com.huawei.agconnect:agcp:1.4.2.300'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
} 

 

  • build.gradle(app) 에 다음을 추가
    • signkey 와 관련된 부분은 Android Studio의 Generate Signed Bundle or APK 를 이용한다면 생략해도 좋다. 하지만 디버그 모드에서도 적용될지는 테스트해봐야 할듯.
apply plugin: 'com.huawei.agconnect'
// android 4.0 부터는 다음 코드 사용
// plugins {
// ...
// 		id 'com.huawei.agconnect'
// }

android { 
	defaultConfig { 
    	... 
        resConfigs "en", "zh-rCN", "Other languages supported by your app" 
    } 
    
    signingConfigs { 
    	config{ 
        	storeFile file('xxx.xxx') 
            keyAlias 'xxx' 
            keyPassword 'xxx' 
            storePassword 'xxx' 
    	} 
	}
    
    buildTypes { 
    	debug { 
        	signingConfig signingConfigs.config 
       	} 
        release { 
        	signingConfig signingConfigs.config 
        	minifyEnabled false 
        	proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 
        } 
  	} 
}
    
dependencies {
	// https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/version-change-history-0000001050065947-V5 
    implementation 'com.huawei.hms:iap:{version}'
}

 

 

build.gradle 에 keystore의 민감한 정보들을 노출하는 것은 바람직하지 않으므로 다음과 같이 수정할 수 있다

  • gadle.properties 에 다음과 같이 정의
SIGNED_STORE_FILE=SampleKeyStore.jks
SIGNED_KEY_ALIAS=key0
SIGNED_STORE_PASSWORD=password1
SIGNED_KEY_PASSWORD=password2

 

  • signingConfig 를 다음과 같이 수정
signingConfigs { 
	config{ 
		storeFile file(SIGNED_STORE_FILE) 
		keyAlias SIGNED_KEY_ALIAS 
		keyPassword SIGNED_STORE_PASSWORD 
		storePassword SIGNED_KEY_PASSWORD 
	} 
}

 

 

Manifest 파일에 다음을 추가

  • targetSdkVersion 이 30 이하
<application ...>
    <meta-data     
       android:name="com.huawei.hms.client.channel.androidMarket"  
       android:value="false" />
    ...
</application>

 

  • targetSdkVersion 이 30 이상
<manifest ...>
    ...
    <queries>
        <intent>
            <action android:name="com.huawei.hms.core.aidlservice" />
        </intent>
    </queries>
    ...
</manifest>

 

  • 난독화 설정
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}

 

 

위 문서는 화웨이 공식 개발 사이트를 참고하여 작성되었습니다. 

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/dev-process-0000001050033070

'Android' 카테고리의 다른 글

화웨이 결제 구현(1) - 개요  (0) 2021.04.12
API27 에뮬레이터에서 결제 안되는 현상  (1) 2021.03.14
MultiDex 에러..?  (0) 2021.03.14
Design Palette 훑어보기 - Layout편  (0) 2020.09.25
Design Palette 훑어보기 - Button편  (0) 2020.09.24