Cant open map fragment - android

I'm trying to add map fragment to activity. For my example I use this official article:https://developers.google.com/maps/documentation/android-api/
But after opening activity with map fragment, my app immediately closed. In logs I have errors like this:
"E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.mw.a"
My gradle:
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "....."
minSdkVersion 14
targetSdkVersion 23
versionCode VERSION_CODE
versionName VERSION_NAME
}
signingConfigs {
debug {
storeFile file("keys/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
}
}
buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
lintOptions {
// If true, stop the gradle build if errors are found.
abortOnError false
htmlReport true
disable "RtlHardcoded", "RtlSymmetry", "RtlEnabled", "RelativeOverlap"
disable 'InvalidPackage'
}
def APK_NAME = PROJECT_NAME + "-" + VERSION_NAME + ".apk"
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (variant.buildType.name.equals("debug")) {
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-debug.apk", APK_NAME))
} else {
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace("app-release.apk", APK_NAME))
}
}
}
}
File propFile = file('signing.properties');
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
if (props.containsKey('RELEASE_STORE_FILE') && props.containsKey('RELEASE_STORE_PASSWORD') &&
props.containsKey('RELEASE_KEY_ALIAS') && props.containsKey('RELEASE_KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['RELEASE_STORE_FILE'])
android.signingConfigs.release.storePassword = props['RELEASE_STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['RELEASE_KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['RELEASE_KEY_PASSWORD']
} else {
android.buildTypes.release.signingConfig = null
}
} else {
android.buildTypes.release.signingConfig = null
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okio:okio:1.6.0'
compile 'com.google.code.gson:gson:2.3'
compile 'org.parceler:parceler:0.2.15'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.pixplicity.easyprefs:library:1.7'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.borax12.materialdaterangepicker:library:1.2'
compile 'io.realm:realm-android:0.84.1'
compile 'com.cocosw:bottomsheet:1.1.1#aar'
compile 'io.socket:socket.io-client:0.6.1'
}
After that, I add multidex possibility according to
Getting error: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza, but it does not resolve the problem.
What can be a problem?

Your targetSdkVersion is 23 and the AppsOpsManager is available in API 19 and above. What you are missing is to add compile 'com.android.support:multidex:1.0.0' or multiDexEnabled true in the build.gradle file in order to enable the multidex function.

Related

Execution failed for task ':app:transformClassesWithInstantRunForClientDebug'

The error
My gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile project(':venuemap')
// compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
// compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
// compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
// compile "com.google.android.gms:play-services:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-plus:$rootProject.playServicesVersion"
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
compile "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"
compile 'com.google.maps.android:android-maps-utils:0.4.4'
// compile 'com.google.maps.android:android-maps-utils:0.4+'
// compile 'com.google.maps.android:android-maps-utils:0.5+'
compile 'net.hockeyapp.android:HockeySDK:4.1.1'
compile 'com.flurry.android:analytics:6.5.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'org.parceler:parceler-api:1.1.9'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.google.firebase:firebase- core:$rootProject.playServicesVersion"
compile 'com.facebook.android:facebook-android-sdk:4.+'
// annotationProcessor 'org.parceler:parceler:1.1.9'
compile('com.crashlytics.sdk.android:answers:1.4.0#aar') {
transitive = true;
}
}
android {
def defaultApplicationId = "com.yamo.android"
def defaultVersionName = "1.1.7"
def buildNumber = "53" // increment when merging with master
def defaultVersionCode = Integer.parseInt(buildNumber)
def buildNumberSuffix = " (" + buildNumber + ")"
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
applicationId defaultApplicationId
versionCode defaultVersionCode
versionName defaultVersionName
vectorDrawables.useSupportLibrary = true
// multiDexEnabled true
}
signingConfigs {
debug {
storeFile rootProject.file("keystore/debug.keystore")
}
release {
storeFile rootProject.file("keystore/release.keystore")
storePassword "password"
keyAlias "locassa"
keyPassword "password"
}
}
buildTypes {
debug {
minifyEnabled true
useProguard false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
useProguard true
shrinkResources true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
live {
versionName defaultVersionName + buildNumberSuffix
}
client {
versionName defaultVersionName + "-CLIENT" + buildNumberSuffix
applicationId defaultApplicationId
}
internal {
versionName defaultVersionName + "-INTERNAL" + buildNumberSuffix
applicationId defaultApplicationId + ".internal"
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
}
//apply from:
rootProject.file('config/checkstyle/checkstyle.gradle')
apply plugin: 'com.google.gms.google-services'
}
When building app, I have got this error.
I am using android studio 2.3.3.
CompileSdkVersion is 26 and buildToolsVersion is 26.0.2.
And my gradle version is 2.3.3.
I have been searching the solution about this problem for several days but I didn't find anything on google.
Please help me to resolve this error. Thanks a lot!
This is your Problem :
compile 'com.facebook.android:facebook-android-sdk:4.+'
Use this :
compile 'com.facebook.android:facebook-android-sdk:4.4.0'

My App's RecycleViews don't have a scrollbar,but it works on a new project

I found this code does't work in my Project.
android:scrollbars="vertical"
But if i set this to a new DEMO,it works.
I think it's about App styles or something in build.gradle,but i try many methods and it's just didn't work(like copy the Application styls from my project to the new project and apply it,it still works),any one else has this problem?
this is my build.gradle code:
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId "com.haixue.app.android.HaixueAcademy.h4"
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 3210
versionName "3.2.1beta"
multiDexEnabled true
resConfigs "zh"
resValue("string", "growingio_project_id", "8701f2e2e096a888")
resValue("string", "growingio_url_scheme", "growing.42190e827fb47099")
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
useLibrary 'org.apache.http.legacy'
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
}
lintOptions {
abortOnError false
xmlReport false
htmlReport true
htmlOutput file("$project.buildDir/reports/lint/lint-result.html")
xmlOutput file("$project.buildDir/reports/lint/lint-result.xml")
}
signingConfigs {
release {
storeFile file("../docs/haixue.keystore")
storePassword "123456"
keyAlias "highso"
keyPassword "123456"
}
debug {
storeFile file("../docs/haixue.keystore")
storePassword "123456"
keyAlias "highso"
keyPassword "123456"
}
}
walle {
apkOutputFolder = new File("${project.buildDir}/outputs/channels");
apkFileNameFormat = '${appName}-${channel}-${buildType}-v${versionName}.apk';
channelFile = new File("${project.getProjectDir()}/channel")
}
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
testCoverageEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace(".apk", "-${defaultConfig.versionName}.apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
//JNI
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir(['libs'])
}
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':RtmpResourceLib')
compile project(':imagepicker')
compile project(':viewPagerlibrary')
compile project(':SlidingMenu')
compile project(':treeviewlist')
compile project(':NodeView')
compile files('libs/jcore-android-1.1.6.jar')
compile files('libs/jpush-android-3.0.8.jar')
compile files('libs/TalkFunSDK.jar')
compile files('libs/alipaySingle-20170510.jar')
compile(name: 'alicloud-android-feedback-3.1.1', ext: 'aar')
compile files('libs/alicloud-android-utils-1.0.3.jar')
compile files('libs/utdid4all-1.1.5.3_proguard.jar')
compile files('libs/alicloud-android-monitor-2.5.1.1_for_bc_proguard.jar')
//noinspection GradleCompatible
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-annotations:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.1'
//compile 'com.tencent.bugly:crashreport:2.6.5' crashreport_upgrade
compile 'com.tencent.bugly:crashreport_upgrade:latest.release'
compile 'com.tencent.bugly:nativecrashreport:latest.release'
compile 'com.growingio.android:vds-android-agent:1.0.3#aar'
compile 'com.umeng.analytics:analytics:latest.integration'
compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:1.0.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.github.Aspsine:SwipeToLoadLayout:1.0.4'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.0'
compile 'com.lzy.net:okgo:2.1.4'
compile 'com.github.hackware1993:MagicIndicator:1.5.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.zhy:autolayout:1.4.5'
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.j256.ormlite:ormlite-android:5.0'
compile 'com.j256.ormlite:ormlite-core:5.0'
compile 'com.meituan.android.walle:library:1.1.3'
compile 'com.zhy:flowlayout-lib:1.0.3'
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'
compile 'com.google.android.exoplayer:exoplayer-core:r2.5.2'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.5.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.3'
compile 'com.kyleduo.switchbutton:library:1.4.6'
}
I figure it out
#android:color/transparent
SomeOthers set this in our App's Style ,this code make the ScrollBar transparent.

./Gradlew Build is taking 2 hours and 40 minutes - Is there any room for improvement?

The app that we are working on is not very large - most of it is an empty application that gets filled in from various endpoints (server side), but we currently have 18 separate flavors of the app that get built.
The issue is, there will be 78 flavors of the application built and if the build time is linear, we are looking at about 11 hours per ./gradlew build request.
Im not well versed in Gradle at all and I was hoping you guys could help me find some problem areas that might be able to improve our build times
Here is the build.gradle:
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
apply from: '../jacoco.gradle'
apply from: '../flavors.gradle'
apply from: '../autoTasks.gradle'
ext {
applicationName = 'OurApp'
supportLibVersion = '25.3.0'
playServicesVersion = '9.6.1'
}
android {
signingConfigs {
debug {
keyAlias 'key'
keyPassword 'pass'
storeFile file('../file.keystore')
storePassword 'pass'
}
release {
keyAlias 'key'
keyPassword 'pass'
storeFile file('../file.jks')
storePassword 'pass'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
vectorDrawables.useSupportLibrary true
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
multiDexEnabled true
}
dataBinding {
enabled true
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField 'String', 'DFP_NETWORK_ID', '"id"'
buildConfigField 'String', 'YOUTUBE_API_KEY', '"ourkey"'
}
debug {
signingConfig signingConfigs.debug
testCoverageEnabled = true
buildConfigField 'String', 'DFP_NETWORK_ID', '"id"'
buildConfigField 'String', 'YOUTUBE_API_KEY', '"anotherKey"'
}
debuggable.initWith(buildTypes.debug)
debuggable {
testCoverageEnabled = false
}
}
dexOptions {
javaMaxHeapSize "4g"
}
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
createZipProguardTask(variant);
}
updateApkName(variant);
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'
annotationProcessor 'com.squareup:javapoet:1.8.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:support-v13:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:preference-v14:${supportLibVersion}"
compile "com.google.android.gms:play-services-gcm:${playServicesVersion}"
compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
compile "com.google.firebase:firebase-core:${playServicesVersion}"
compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.roughike:bottom-bar:2.2.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.l4digital.rxloader:rxloader:2.0.1'
compile 'com.bluelinelabs:logansquare:1.3.7'
compile 'com.github.aurae.retrofit2:converter-logansquare:1.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.google.dagger:dagger:2.7'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true
}
compile(name:'googlemediaframework-release', ext:'aar')
compile "com.google.android.gms:play-services-ads:${playServicesVersion}"
compile "com.google.android.gms:play-services-analytics:${playServicesVersion}"
compile 'com.flurry.android:ads:6.2.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.google.android.exoplayer:exoplayer:r1.5.14'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
debuggableCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.okhttp3:okhttp:3.5.0'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile('com.android.support.test:rules:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile (name:'cloudtestingscreenshotter_lib', ext:'aar')
androidTestCompile('com.android.support.test:runner:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
exclude module: 'support-annotations'
}
compile(name:'MapSDK', ext:'aar')
compile('com.twitter.sdk.android:twitter:2.3.2#aar') {
transitive = true;
}
}
def createZipProguardTask(variant) {
def prefix = project.ext.applicationName;
if (project.hasProperty('buildNumber')) {
prefix += '-' + project.getProperties().get('buildNumber');
}
def taskName = variant.flavorName.substring(0, 1).toUpperCase() + variant.flavorName.substring(1);
task("zipProguard${taskName}", type: Zip) {
archiveName = "${prefix}-${variant.flavorName}-proguard.zip";
from "build/outputs/mapping/${variant.flavorName}/release"
destinationDir file('build/outputs/mapping')
}
}
def updateApkName(variant) {
def prefix = project.ext.applicationName;
if (project.hasProperty('buildNumber')) {
prefix += '-' + project.getProperties().get('buildNumber');
}
variant.outputs.each { output ->
def fileName = output.outputFile.name.replace('app', prefix);
def outputFile = new File(output.outputFile.parent.toString(), fileName.toString());
output.outputFile = outputFile;
}
}
Here is what we have in the gradle properties:
org.gradle.jvmargs=-Xmx4608M -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.daemon=true
Any input would be greatly appreciated - like I said, I'm not well versed in gradle at all, so I'm open to anything.
Thank you in advance
I'm sure you figured something out by now, but just for future googlers -
Android Studio gradle takes too long to build improved the speed of my gradle build drastically. It suggests enabling Offline work in Android Studio by going to file>settings>build, execution, deployment>gradle and checking the "Offline work" option.

Failure [INSTALL_FAILED_NO_MATCHING_ABIS] error when trying to install/run android app on phone (not emulator)

I'm getting a install failed error due to no matching ABIS when I try to run my app on my phone from android studio but I'm not sure how this can be the case since I'm using a phone and not an emulator. I have uninstalled the existing app, restarted the phone, restarted my computer, and updated android studio and gradle to no luck. I'm not sure what could cause this since it's (to my understanding) due to problems with emulated architectures. It should be noted that the error only started recently and without any noticeable changes in my version history. I'm on an htc one m8(which uses a snapdragon 801 processor with an arm v7 rev. 1 architecture) running android 6.0 and My app level gradle build is as follows:
android {
compileSdkVersion 23
buildToolsVersion '24.0.2'
defaultConfig {
applicationId "REDACTED"
minSdkVersion getMinSdk()
targetSdkVersion 22
versionCode 131
versionName "1.2.58"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
signingConfigs {
debug {
storeFile rootProject.file("keys/debug.keystore")
v2SigningEnabled false
}
release {
REDACTED
}
}
buildTypes {
release {
buildConfigField "boolean", "CRASHLYTICS", "true"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.betaDistributionGroupAliases = "testers"
signingConfig signingConfigs.release
}
debug {
buildConfigField "boolean", "CRASHLYTICS", "false"
ext.betaDistributionGroupAliases = "testers"
applicationIdSuffix ".debug"
}
staging.initWith(buildTypes.debug)
staging {
buildConfigField "boolean", "CRASHLYTICS", "true"
ext.betaDistributionGroupAliases = "testers"
applicationIdSuffix ".staging"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
sourceSets {
main {
svg.srcDir 'src/main/svg'
}
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'mips', 'x86'
universalApk true
}
}
}
victor {
// Do not generate these densities for SVG assets
excludeDensities = ['ldpi']
}
def getMinSdk() {
for (String taskName : project.getGradle().startParameter.taskNames) {
if (taskName.toLowerCase().contains("debug")) {
return 21
}
}
return 15
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'io.branch.sdk.android:library:1.+'
compile 'com.trello:rxlifecycle:0.6.1'
compile 'jp.wasabeef:recyclerview-animators:1.3.0#aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') { transitive = true; }
compile('com.facebook.android:facebook-android-sdk:4.10.1') { exclude module: 'support-v4' }
compile('com.twitter.sdk.android:twitter-core:1.6.6#aar') { transitive = true; }
compile('com.twitter.sdk.android:tweet-composer:1.0.5#aar') {
transitive = true;
}
compile 'com.appyvet:materialrangebar:1.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0#aar'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton.timber:timber:3.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okio:okio:1.6.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup:otto:1.3.8'
compile 'io.reactivex:rxjava:1.1.8'
compile 'com.jakewharton.rxrelay:rxrelay:1.0.0'
compile 'io.reactivex:rxandroid:1.1.0'
apt 'com.google.dagger:dagger-compiler:2.5'
compile 'com.google.dagger:dagger:2.5'
provided 'org.glassfish:javax.annotation:10.0-b28'
debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
stagingCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
// Filter is null for universal APKs.
def filter = output.getFilter(OutputFile.ABI)
if (!android.splits.abi.universalApk) {
// change the version codes
output.versionCodeOverride =
project.ext.versionCodes.get(filter) * 1000000 + android.defaultConfig.versionCode
}
if (filter == null) {
tasks.findAll {
it.name.startsWith(
"crashlyticsUploadDistribution${variant.name.capitalize()}")
}.each {
it.doFirst {
ext.betaDistributionApkFilePath = output.outputFile.absolutePath
}
}
}
if (filter == null) {
tasks.findAll {
it.name.startsWith(
"crashlyticsUploadSymbols${variant.name.capitalize()}")
}.each {
it.doFirst {
ext.betaDistributionApkFilePath = output.outputFile.absolutePath
}
}
}
}
}
apply plugin: 'com.google.gms.google-services'

How to change suffix of apk based on buildtype

I want to change the generated name of the .apk file in my build gradle. based on which buildtype i choose. It automatically appends "-release" or "-debug".
How can I change this?
Build gradle file
android {
signingConfigs {
testapp {
storeFile file("itsASecret")
storePassword "itsASecret"
keyAlias "itsASecret"
keyPassword "itsASecret"
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
def versionPropertiesFile = file('version.properties')
if (versionPropertiesFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropertiesFile))
def code = versionProps['VERSION_CODE'].toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropertiesFile.newWriter(), null)
defaultConfig
{
applicationId "com.testapp.app"
minSdkVersion 19
targetSdkVersion 22
versionCode code
versionName "1.02.00"
multiDexEnabled true
setProperty("archivesBaseName", "TestApp_" + "$versionName" + "_" + "$versionCode")
}
} else {
throw new GradleException("Could not read version.properties!")
}
buildTypes
{
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.testapp
}
debug {
debuggable true
signingConfig signingConfigs.testapp
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
signingConfig signingConfigs.railway
}
}
I tried something like
applicationIdSuffix "_DEBUGTEST"
or
versionNameSuffix "_DEBUGTEST"
Filename:
TestApp_1.02.00_458-release.apk
TestApp_1.02.00_458-debug.apk
But this is not working :-(
EDIT:
I do have a common library with another build gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'de.greenrobot:greendao:1.3.7'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-codec:commons-codec:1.10'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile 'log4j:log4j:1.2.16'
compile 'org.slf4j:slf4j-api:1.6.4'
compile 'org.slf4j:slf4j-log4j12:1.6.4'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'commons-net:commons-net:3.3'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'com.jjoe64:graphview:4.0.1'
}

Categories

Resources