blob: 261c7f0fe58e86ddd4a2581cf11615c7770509c5 [file] [log] [blame]
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
// Load the build signing secrets from a local `keystore.properties` file.
// TODO(YOU): Create release keys and a `keystore.properties` file. See
// `example/README.md` for more info and `keystore.example.properties` for an
// example.
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
def configured = true
try {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
} catch (IOException e) {
configured = false
logger.error('Release signing information not found.')
}
project.ext {
// TODO(YOU): Create release keys and a `keystore.properties` file. See
// `example/README.md` for more info and `keystore.example.properties` for an
// example.
APP_ID = configured ? keystoreProperties['appId'] : "io.flutter.plugins.inapppurchaseexample.DEFAULT_DO_NOT_USE"
KEYSTORE_STORE_FILE = configured ? rootProject.file(keystoreProperties['storeFile']) : null
KEYSTORE_STORE_PASSWORD = keystoreProperties['storePassword']
KEYSTORE_KEY_ALIAS = keystoreProperties['keyAlias']
KEYSTORE_KEY_PASSWORD = keystoreProperties['keyPassword']
VERSION_CODE = configured ? keystoreProperties['versionCode'].toInteger() : 1
VERSION_NAME = configured ? keystoreProperties['versionName'] : "0.0.1"
}
if (project.APP_ID == "io.flutter.plugins.inapppurchaseexample.DEFAULT_DO_NOT_USE") {
configured = false
logger.error('Unique package name not set, defaulting to "io.flutter.plugins.inapppurchaseexample.DEFAULT_DO_NOT_USE".')
}
// Log a final error message if we're unable to create a release key signed
// build for an app configured in the Play Developer Console. Apks built in this
// condition won't be able to call any of the BillingClient APIs.
if (!configured) {
logger.error('The app could not be configured for release signing. In app purchases will not be testable. See `example/README.md` for more info and instructions.')
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
signingConfigs {
release {
storeFile project.KEYSTORE_STORE_FILE
storePassword project.KEYSTORE_STORE_PASSWORD
keyAlias project.KEYSTORE_KEY_ALIAS
keyPassword project.KEYSTORE_KEY_PASSWORD
}
}
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId project.APP_ID
minSdkVersion 16
targetSdkVersion 28
versionCode project.VERSION_CODE
versionName project.VERSION_NAME
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
// Google Play Billing APIs only work with apps signed for production.
debug {
if (configured) {
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
}
release {
if (configured) {
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.android.billingclient:billing:1.2'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.17.0'
testImplementation 'org.json:json:20180813'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}