build.gradle 4.24 KB
Newer Older
1
2
3
4
5
6
7
apply plugin: 'com.android.application'

android {
    //the compression of webp file during build causes problem with FileDescriptor in ContentProvider.
    aaptOptions {
        noCompress "webp"
    }
Simon Xu's avatar
Simon Xu committed
8
    compileSdkVersion 30
9
    defaultConfig {
10
        applicationId "com.example.samplestickerapp2"
11
        minSdkVersion 15
Simon Xu's avatar
Simon Xu committed
12
        targetSdkVersion 30
13
14
        versionCode 1
        versionName "1.0"
ar-arvind's avatar
ar-arvind committed
15
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16
17
18
19
20
21
22
23
24
25
26
27
        def contentProviderAuthority = applicationId + ".stickercontentprovider"
        // Creates a placeholder property to use in the manifest.
        manifestPlaceholders =
                [contentProviderAuthority: contentProviderAuthority]
        // Adds a new field for the authority to the BuildConfig class.
        buildConfigField("String",
                "CONTENT_PROVIDER_AUTHORITY",
                "\"${contentProviderAuthority}\"")
    }
    buildTypes {
        debug {
            minifyEnabled false
ar-arvind's avatar
ar-arvind committed
28
            shrinkResources false
ar-arvind's avatar
ar-arvind committed
29
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
30
31
32
        }
        release {
            minifyEnabled true
ar-arvind's avatar
ar-arvind committed
33
            shrinkResources true
ar-arvind's avatar
ar-arvind committed
34
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
35
36
37
        }
    }
    compileOptions {
Arvind's avatar
Arvind committed
38
39
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
40
    }
41
42
43
44
45

    packagingOptions {
        exclude 'lib/*/libnative-imagetranscoder.so'
        exclude 'lib/*/libnative-filters.so'
    }
46
47
48
49
50
51

    // Configures multiple APKs based on ABI.
    // see https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
//    splits {
//        abi {
//            enable true // Enables building multiple APKs per ABI.
ar-arvind's avatar
ar-arvind committed
52
//            universalApk true // Specifies that we want to also generate a universal APK that includes all ABIs.
53
54
//        }
//    }
55
56
57
58
59
60
}

task checkDebug {
    doLast {
        println("checkDebug")
        if (android.defaultConfig.applicationId.startsWith("com.whatsapp")) {
ar-arvind's avatar
ar-arvind committed
61
            throw new GradleException("applicationId in defaultConfig cannot start with com.whatsapp, please change your applicationId in app/build.gradle")
62
63
64
65
66
67
68
69
70
71
        }
        checkApplicationIdInDebug()
    }
}

private void checkApplicationIdInDebug() {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ignoreApplicationIdCheck = properties.getProperty('ignoreApplicationIdCheck')
    if (ignoreApplicationIdCheck == null) {
ar-arvind's avatar
ar-arvind committed
72
73
        if (android.defaultConfig.applicationId == "com.example.samplestickerapp") {
            throw new GradleException("Your applicationId is currently com.example.samplestickerapp, please change your applicationId to a different string in app/build.gradle in line 10")
74
75
76
77
78
79
80
81
82
83
84
        }
    } else {
        println("application id check ignored")
    }
}


task checkRelease {
    doLast {
        println("checkRelease")
        if (android.defaultConfig.applicationId.startsWith("com.example")) {
ar-arvind's avatar
ar-arvind committed
85
            throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle")
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
        }
    }
}

tasks.whenTaskAdded { task ->
    println(task.name)
    if (task.name.contains("assembleDebug")) {
        task.dependsOn checkDebug
    }
    if (task.name.contains("assembleRelease")) {
        task.dependsOn checkRelease
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
103
104
105
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.13.2'
Simon Xu's avatar
Simon Xu committed
106
107
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
108
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
Simon Xu's avatar
Simon Xu committed
109
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
110
    def fresco_version = '2.3.0'
ar-arvind's avatar
ar-arvind committed
111
112
113
114
    implementation "com.facebook.fresco:fresco:$fresco_version"
    implementation "com.facebook.fresco:webpsupport:$fresco_version"
    implementation "com.facebook.fresco:animated-webp:$fresco_version"
    implementation "com.facebook.fresco:animated-base:$fresco_version"
115
}