After update to Android 10 api version 29, SQLite database crashes - android

After updating my project to android 10 I got crash on database open.
Logcat report:
2020-11-16 09:27:52.091 20196-22102/? E/SQLiteDatabase: Failed to open database '/data/user/0/bezeq.gala.preprod/databases/bezeqlocator.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 1294 SQLITE_CANTOPEN_ENOENT[1294]): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:300)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:218)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:737)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1386)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1331)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:994)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:940)
at com.bezeq.locator.dao.db.DBHelper.checkDataBase(DBHelper.java:210)
at com.bezeq.locator.dao.db.DBHelper.create(DBHelper.java:154)
at com.bezeq.locator.service.services.OnStartService$CreateDbFromFile.doInBackground(OnStartService.java:113)
at com.bezeq.locator.service.services.OnStartService$CreateDbFromFile.doInBackground(OnStartService.java:101)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "bezeq.gala"
minSdkVersion 24
targetSdkVersion 29
versionCode 71
versionName "15.0.71"
multiDexEnabled true
project.ext.set("archivesBaseName", "bview-" + defaultConfig.versionName);
}
dexOptions {
javaMaxHeapSize "4096M"
}
signingConfigs {
release {
keyAlias 'gala'
storeFile file('\\\\amam\\root\\oss\\BVieW\\Keys\\gala_signature_key.jks')
keyPassword System.getenv("BviewKeystorePassword")
storePassword System.getenv("BviewKeystorePassword")
}
}
buildTypes {
def PERMISSIONS_SYSTEM_SYMBOL = "PERMISSIONS_SYSTEM_SYMBOL"
def REST_API_URL = "REST_API_URL"
localhost_emulator {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://10.0.2.2:8080/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
localhost_device {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://localhost:5000/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
debug {
applicationIdSuffix ".dev"
debuggable true
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALD"';
buildConfigField 'String', REST_API_URL, '"http://vm-tbvwwebt1.bezeq.com:8180/gala"';
manifestPlaceholders = [appName: "BVieW Dev"]
}
tst { // Build types may not start with 'test'
applicationIdSuffix ".tst"
debuggable false
signingConfig signingConfigs.release
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALT"';
buildConfigField 'String', REST_API_URL, '"http://vm-tbvwwebt1.bezeq.com:8180/gala"';
manifestPlaceholders = [appName: "BVieW Test"]
}
release {
debuggable false
// minifyEnabled true
signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', PERMISSIONS_SYSTEM_SYMBOL, '"GALA"';
buildConfigField 'String', REST_API_URL, '"http://bview.bezeq.com/gala"';
manifestPlaceholders = [appName: "BVieW"]
}
preprod {
initWith release
applicationIdSuffix ".preprod"
manifestPlaceholders = [appName: "BVieW PreProd"]
}
}
flavorDimensions "version"
productFlavors {
regular {
dimension "version"
}
skip_login {
dimension "version"
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
}
}
repositories {
maven { url "https://mint.splunk.com/gradle/" }
maven { url "https://repo.spring.io/release" }
jcenter()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//multidex suppport for android < 5.0
implementation 'androidx.multidex:multidex:2.0.1'
//design stuff
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
//google stuff
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places-compat:2.2.0'
//mint (crash report & statistics)
implementation 'com.splunk.mint:mint:4.0.9'
//spring framework
implementation 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
implementation 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
//sliding panel
implementation 'com.sothree.slidinguppanel:library:3.3.1'
//circle image
implementation 'de.hdodenhof:circleimageview:2.1.0'
//usb serial connection
implementation 'com.github.felHR85:UsbSerial:4.5'
}

Related

Plugin with id 'com.onesignal.androidsdk.GradleProjectPlugin' not found

I'm trying to run my code in android studio
this is my error
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with
id 'com.onesignal.androidsdk.GradleProjectPlugin' not found.
This is my module code :
apply plugin: "com.android.application" apply from: "../utils.gradle"
apply plugin: "com.onesignal.androidsdk.GradleProjectPlugin"
android { compileSdkVersion 32 buildToolsVersion "30.0.3"
defaultConfig { applicationId "com.zakat" minSdkVersion 19
targetSdkVersion 32 versionCode getVersionCode(VERSION_MAJOR,
VERSION_MINOR, VERSION_PATCH, VERSION_BUILD) versionName
getVersionName(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
multiDexEnabled true vectorDrawables.useSupportLibrary = true }
signingConfigs { release { def keystoreProperties =
getKeystoreProperties
file("../${project.property('keystore.properties')}") storeFile
file("../${project.property('keystore.file')}") storePassword
keystoreProperties["keystore.store.password"] keyAlias
keystoreProperties["keystore.key.alias"] keyPassword
keystoreProperties["keystore.key.password"] } }
buildTypes { debug { buildConfigField "boolean", "LOGS", "true"
buildConfigField "boolean", "DEV_ENVIRONMENT", "true"
buildConfigField "boolean", "TEST_ADS", "false"
versionNameSuffix "-debug" }
release { buildConfigField "boolean", "LOGS", "false"
buildConfigField "boolean", "DEV_ENVIRONMENT", "false"
buildConfigField "boolean", "TEST_ADS", "false"
signingConfig signingConfigs.release zipAlignEnabled true
minifyEnabled false shrinkResources false proguardFiles
getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
} }
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 }
setProperty("archivesBaseName", getArtifactName(defaultConfig))
// workaround for https://issuetracker.google.com/issues/141132133
configurations.all { resolutionStrategy { force
"androidx.appcompat:appcompat:1.2.0-rc02" } } }
dependencies { implementation fileTree(dir: "libs", include:
["*.jar"]) implementation(name: "config", ext: "aar") implementation
"androidx.appcompat:appcompat:1.2.0-rc02" // workaround for
https://issuetracker.google.com/issues/141132133 implementation
"androidx.fragment:fragment:1.2.5" implementation
"androidx.multidex:multidex:2.0.1" implementation
"com.google.android.ads.consent:consent-library:1.0.8" implementation
"com.google.android.material:material:1.1.0" implementation
"com.google.firebase:firebase-ads:19.3.0" implementation
"com.google.firebase:firebase-analytics:17.4.4" implementation
"com.google.firebase:firebase-messaging:20.2.4" implementation
"com.onesignal:OneSignal:3.15.1" implementation
"org.alfonz:alfonz-utility:0.9.2" implementation
"org.alfonz:alfonz-view:0.9.2" classpath
"gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.0"
//classpath
"gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1,
0.99.99]" classpath "com.google.gms:google-services:4.2.0" }
apply plugin: "com.google.gms.google-services"
Can anyone help me? Thank you

Getting error in build.gradle : No signature of method: build_2gzryvmsr2xvhzda2muxrnzeq.android() is applicable for argument types

I'm trying to define product flavors like this but getting error in the same:
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.test.test"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding {
enabled = true
}
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions 'default'
productFlavors {
uat {
applicationId "com.test.test"
versionCode 1
versionName "1.0.0"
buildConfigField "String", 'HOST', '""'
resValue 'string', 'app_name', "Test"
isDefault.set(true)
}
prod {
applicationId "com.test.test"
versionCode 1
versionName "1.0.0"
buildConfigField "String", 'HOST', '""'
resValue 'string', 'app_name', "Test"
}
}
aaptOptions {
cruncherEnabled = false
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Resize library
implementation 'com.intuit.sdp:sdp-android:1.0.6'
//Spinkit
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
//Retrofit & GSON Parsing
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okio:okio:2.8.0'
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:okhttp-urlconnection")
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation "com.squareup.moshi:moshi-adapters:1.5.0"
}
Here's the error
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
Caused by: groovy.lang.MissingMethodException: No signature of method: build_2gzryvmsr2xvhzda2muxrnzeq.android() is applicable for argument types: (build_2gzryvmsr2xvhzda2muxrnzeq$_run_closure1) values: [build_2gzryvmsr2xvhzda2muxrnzeq$_run_closure1#64cb0e38]
at build_2gzryvmsr2xvhzda2muxrnzeq.run
Can anyone help me with this?
Thanks in advance.
The problem is here:
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
delete useProguard true the problem will be resolved

I have a problem loading widgets in android studio

I do not know why this problem happened I opened my android studio and it does not load the view of my RecyclerView and some other widgets, since I cleaned the cache also used the Rebuild Project but the problem persists, I would appreciate your support
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="#android:color/transparent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:listitem="#layout/item_list_specialties_list"
tools:itemCount="6"
tools:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:spanCount="1" />
</RelativeLayout>
here is the buildgradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply from: "$rootProject.rootDir/app/config.gradle" //Compile Play Store
//apply from: "$rootProject.rootDir/app/config-share-fabric.gradle" //Compile Fabric
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file("keystore.properties")
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
def serverProperties = new Properties()
def serverPropertiesFile = rootProject.file("server.properties")
serverProperties.load(new FileInputStream(serverPropertiesFile))
def configuration = ext.configuration
def configurationUser = ext.configurationUser
def configurationSpecialist = ext.configurationSpecialist
def configurationSeller = ext.configurationSeller
android {
compileSdkVersion configuration.compileSdk
buildToolsVersion configuration.buildTools
defaultConfig {
applicationId configuration.applicationId
minSdkVersion configuration.minimumSdk
targetSdkVersion configuration.targetSdk
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testHandleProfiling true
testFunctionalTest true
multiDexEnabled true
resConfigs("es", "en")
manifestPlaceholders = [
projectName : configuration.projectName,
fabricApiKey: "17fdb5821b7ac5a50e3250fb679a180d9ab54889"
]
resValue("string", "project_name", "\"${configuration.projectName}\"")
// Used by Room, to test migrations
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
//See https://stackoverflow.com/a/36931232
/*sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/res/drawable',
'src/main/res/drawable/splash',
'src/main/res/drawable/selectors'
]
}
}*/
signingConfigs {
debug {
keyAlias keystoreProperties['keyAliasDebug']
keyPassword keystoreProperties['keyPasswordDebug']
storeFile file(keystoreProperties['storeFileDebug'])
storePassword keystoreProperties['storePasswordDebug']
}
configReleaseUser {
keyAlias keystoreProperties['keyAliasUser']
keyPassword keystoreProperties['keyPasswordUser']
storeFile file(keystoreProperties['storeFileUser'])
storePassword keystoreProperties['storePasswordUser']
}
configReleaseSpecialist {
keyAlias keystoreProperties['keyAliasSpecialist']
keyPassword keystoreProperties['keyPasswordSpecialist']
storeFile file(keystoreProperties['storeFileSpecialist'])
storePassword keystoreProperties['storePasswordSpecialist']
}
configReleaseSeller {
keyAlias keystoreProperties['keyAliasSeller']
keyPassword keystoreProperties['keyPasswordSeller']
storeFile file(keystoreProperties['storeFileSeller'])
storePassword keystoreProperties['storePasswordSeller']
}
}
flavorDimensions "app", "server"
productFlavors {
user {
dimension "app"
applicationId configurationUser.applicationId
versionCode configurationUser.versionCode
versionName "${configurationUser.versionMajor}.${configurationUser.versionMinor}" +
".${configurationUser.versionPath}-${configurationUser.versionClasifier}"
proguardFile 'user-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.user"
}
specialist {
dimension "app"
applicationId configurationSpecialist.applicationId
versionCode configurationSpecialist.versionCode
versionName "${configurationSpecialist.versionMajor}.${configurationSpecialist.versionMinor}" +
".${configurationSpecialist.versionPath}-${configurationSpecialist.versionClasifier}"
proguardFile 'specialist-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.specialist"
}
seller {
dimension "app"
applicationId configurationSeller.applicationId
versionCode configurationSeller.versionCode
versionName "${configurationSeller.versionMajor}.${configurationSeller.versionMinor}" +
".${configurationSeller.versionPath}-${configurationSeller.versionClasifier}"
proguardFile 'seller-proguard-rules.pro'
testApplicationId "pe.com.linkup.android.test.seller"
}
//Desarrollo Local
local {
dimension "server"
applicationIdSuffix ".local"
}
//Desployment Fabric
dev {
dimension "server"
applicationIdSuffix ".dev"
}
//Desployment PlayStore - Testing
staging {
dimension "server"
//applicationIdSuffix ".staging"
}
//Desployment PlayStore - Production
production {
dimension "server"
}
}
// Configura específicamente cada Flavor
productFlavors.all { flavor ->
switch (flavor.name) {
case "user":
flavor.manifestPlaceholders.put("appName", configurationUser.appName)
flavor.resValue("string", "app_name", "\"${configurationUser.appName}\"")
break
case "specialist":
flavor.manifestPlaceholders.put("appName", configurationSpecialist.appName)
flavor.resValue("string", "app_name", "\"${configurationSpecialist.appName}\"")
break
case "seller":
flavor.manifestPlaceholders.put("appName", configurationSeller.appName)
flavor.resValue("string", "app_name", "\"${configurationSeller.appName}\"")
break
case "local":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlLocal']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdLocal']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretLocal']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeLocal']}\"")
break
case "dev":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlDev']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdDev']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretDev']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeDev']}\"")
break
case "staging":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlStaging']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdStaging']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretStaging']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeStaging']}\"")
break
case "production":
flavor.buildConfigField("String", "BASE_URL", "\"${serverProperties['baseUrlProduction']}\"")
flavor.buildConfigField("String", "CLIENT_ID", "\"${serverProperties['clientIdProduction']}\"")
flavor.buildConfigField("String", "CLIENT_SECRET", "\"${serverProperties['clientSecretProduction']}\"")
flavor.buildConfigField("String", "GRANT_TYPE", "\"${serverProperties['grantTypeProduction']}\"")
break
default:
break
}
}
// Configura las variantes merged. Ejm: applicationId ya viene unido con el applicationIdSuffix
applicationVariants.all { variant ->
def name = variant.name
if (name.contains("Local")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Dev")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Staging")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
} else if (name.contains("Production")) {
def filesAuthorityValue = variant.applicationId + ".fileProvider"
variant.mergedFlavor.manifestPlaceholders.put("filesAuthority", filesAuthorityValue)
variant.buildConfigField("String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\"")
}
}
buildTypes {
debug {
//applicationIdSuffix ".debug"
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.user.signingConfig signingConfigs.debug
productFlavors.specialist.signingConfig signingConfigs.debug
productFlavors.seller.signingConfig signingConfigs.debug
buildConfigField "boolean", "LOG", "true"
// disable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
relebug {
//applicationIdSuffix ".relebug"
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "LOG", "true"
// disable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
matchingFallbacks = ['release']
}
release {
zipAlignEnabled true
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.user.signingConfig signingConfigs.configReleaseUser
productFlavors.specialist.signingConfig signingConfigs.configReleaseSpecialist
productFlavors.seller.signingConfig signingConfigs.configReleaseSeller
buildConfigField "boolean", "LOG", "false"
// enable crashlytics
buildConfigField "boolean", "ENABLE_CRASHLYTICS", "true"
ext.enableCrashlytics = true
}
}
// Ignora algunas variantes de compilación para su visualización en la BuildVariant
variantFilter { variant ->
def app = variant.getFlavors().get(0).name
def server = variant.flavors.get(1).name
def isRelease = variant.buildType.name.contains('release')
def isRelebug = variant.buildType.name.contains('relebug')
def isDebug = variant.buildType.name.contains('debug')
if (server.contains('local')) {
variant.setIgnore(false)
} else if (server.contains('dev')) {
variant.setIgnore(false)
} else if (server.contains('staging')) {
variant.setIgnore(false)
} else if (server.contains('production')) {
variant.setIgnore(true) //Temporal
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
lintConfig file("../lint.xml")
}
dexOptions {
jumboMode true
//incremental true
}
testOptions {
reportDir "$rootDir/test-reports"
resultsDir "$rootDir/test-results"
unitTests {
returnDefaultValues = true
all {
jvmArgs '-XX:MaxPermSize=256m'
if (it.name == 'testDebugUnitTest') {
systemProperty 'debug', 'true'
}
}
}
}
//Renombrar Apk de salida
applicationVariants.all { variant ->
variant.outputs.all { output ->
def projectName = "linkup"
def formattedDate = new Date().format('yyyyMMdd', TimeZone.getTimeZone("UTC"))
def apkName = "${projectName}-${variant.flavorName}-${variant.versionName}-${variant.versionCode}-${formattedDate}-${variant.buildType.name}" + ".apk"
def apkDirectory = "${output.outputFile.parent}/apk/${variant.flavorName}/${variant.buildType.name}"
//outputFileName = new File(apkDirectory, apkName)
outputFileName = apkName
}
}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
}
repositories {
jcenter()
google()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
apply from: "$rootProject.rootDir/app/library.gradle"
def library = ext.library
def libraryTest = ext.libraryTest
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation library.support_appcompat
implementation library.support_recyclerview
implementation library.support_v4
implementation library.support_v13
implementation library.support_design
implementation library.support_cardview
implementation library.support_customtabs
implementation library.support_annotations
implementation library.support_vector_drawable
implementation library.support_constraint
implementation library.support_multidex
implementation library.firebase_core
implementation library.firebase_auth
implementation library.firebase_database
implementation library.firebase_storage
implementation library.firebase_messaging
implementation library.firebase_config
implementation library.firebase_invites
implementation library.exoplayer_core
implementation library.exoplayer_ui
implementation library.exoplayer_dash
implementation library.butterknife
annotationProcessor library.butterknife_compiler
implementation library.retrofit2
implementation library.retrofit2_converter_gson
implementation library.logging_interceptor
implementation library.glide
implementation library.joda_time
implementation library.shortcut_badger
implementation library.smiley_rating
//Room
implementation library.room
annotationProcessor library.room_compiler
implementation library.room_assets
//GMS
implementation library.play_services_location
implementation library.play_services_maps
// Crashlytics
implementation(library.crashlytics) {
transitive = true
}
// Crashlytics NDK
implementation(library.crashlytics_ndk) {
transitive = true
}
implementation library.spinner_date_picker
//Testing
testImplementation libraryTest.junit
testImplementation libraryTest.mockito_core
testImplementation libraryTest.robolectric
testImplementation libraryTest.robolectric_shadows
//UI testing
// Espresso dependenciesVersions
androidTestImplementation(libraryTest.expresso_core, {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
configurations.all {
resolutionStrategy.force library.support_annotations
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
}
//TODO: Pendiente -> https://howards543.ddns.net/gradle-script-with-multi-flavor-resource-management/
task("copyGoogleServicesJson", type: Copy) {
println 'copyGoogleServicesJson'
from('$rootProject.rootDir/app/services/dev/google-services.json')
into("$rootProject.rootDir/app")
include('*.json')
}
//apply from: "$rootProject.rootDir/setup/artifacts.gradle"
apply plugin: 'com.google.gms.google-services'
Just based on the dependencies, these were added correctly and the code did not move, my buildgradle structure it in this way where I use library.gradle to call the libraries by version and this is the specic code of the implementation of the RecyclerView.
ext.versions = [
supportLib : '28.0.0'
]
def version = ext.versions
ext.library = [
support_recyclerview : 'com.android.support:recyclerview-v7:' + version.supportLib
]
Use Fragment with RecyclerView and Activity host for this Fragment.

Generate different gradle constants for different flavours and different build types - Android

The requirement is pretty simple. But i am not finding any way to do that.
I have an app with two flavours : original and black.
productFlavors {
original {
}
black {
applicationIdSuffix ".black"
versionNameSuffix "-black"
}
}
Each flavour is having two build types : debug and release
I am generating a runtime gradle constant "APP_INFO" for different build types.
buildTypes {
debug {
buildConfigField "String", "APPINFO", "DEBUG"
signingConfig signingConfigs.debug
}
release {
buildConfigField "String", "APPINFO", "RELEASE"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
What i am getting right now for BuildConfig.APPINFO
flavour : original , buildType : debug. APPINFO "DEBUG"
flavour : original , buildType : release. APPINFO "RELEASE"
flavour : black , buildType : debug. APPINFO "DEBUG"
flavour : black , buildType : release. APPINFO "RELEASE"
I need required value of APPINFO for given flavour and BuildTypes :
flavour : original , buildType : debug. APPINFO should be "DEBUG_ORIGINAL"
flavour : original , buildType : release. APPINFO should be "RELEASE_ORIGINAL"
flavour : black , buildType : debug. APPINFO should be "DEBUG_BLACK"
flavour : black , buildType : release. APPINFO should be "RELEASE_BLACK"
My Gradle File is as below :
apply plugin: 'com.android.application'
android {
signingConfigs {
release {
}
debug {
}
}
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
applicationId "com.lifeyup.app.xyz"
minSdkVersion 19
targetSdkVersion 27
versionCode 7
versionName "1.0.7"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
productFlavors {
original {
}
black {
applicationIdSuffix ".black"
versionNameSuffix "-black"
}
}
buildTypes {
debug {
original {
buildConfigField "String", "APPINFO", "DEBUG_ORIGINAL"
signingConfig signingConfigs.debug
}
black{
buildConfigField "String", "APPINFO", "DEBUG_BLACK"
signingConfig signingConfigs.debug
}
}
release {
original {
buildConfigField "String", "APPINFO", "RELEASE_ORIGINAL"
signingConfig signingConfigs.debug
}
release {
buildConfigField "String", "APPINFO", "RELEASE_BLACK"
signingConfig signingConfigs.release
}
}
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'org.jsoup:jsoup:1.10.3'
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-config:11.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Thanks in advance.
You can use BuildConfig.DEBUG which returns a boolean to check if build is debug or release and for checking the build flavor just check BuildConfig.FLAVOR
for example :
For original flavor and debug build set APPINFO as
if(BuildConfig.DEBUG && BuildConfig.FLAVOR.equalsIgnoreCase("original")) {
APPINFO = "DEBUG_ORIGINAL"
} else {
// other cases
}
try replacing below code for build types section:
buildTypes {
debug {
signingConfig signingConfigs.debug
productFlavors {
original {
buildConfigField "String", "APPINFO", "DEBUG_ORIGINAL"
}
black {
buildConfigField "String", "APPINFO", "DEBUG_BLACK"
}
}
}
release {
signingConfig signingConfigs.debug
productFlavors {
original {
buildConfigField "String", "APPINFO", "RELEASE_ORIGINAL"
}
black {
buildConfigField "String", "APPINFO", "RELEASE_BLACK"
}
}
}
}
Then you can try below code also. This will work for you :
debug {
productFlavors {
original {
buildConfigField "String", "APPINFO", "DEBUG_ORIGINAL"
}
black {
buildConfigField "String", "APPINFO", "DEBUG_BLACK"
}
}
}
release {
//// similarly for release here
}

Is there any way to check which of part is expanding most after installation?

My 3MB App(used proguard to reduce size) on Play-store but after installation, it becomes 22MB. I want to reduce this 22MB size on phone to somewhere 8 to 10MB
Anybody know any tool which will tell who is taking most size after installation?? so that I can reduce that part of the app or remove that features from the app.
below is highligted part for which i want to see distribution
on #Ankita request
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
signingConfigs {
release_config {
keyAlias 'XXXX'
keyPassword 'XXXX'
storeFile file('F:\\key.jks')
storePassword 'XXXX'
}
}
compileSdkVersion 25
buildToolsVersion '26'
defaultConfig {
applicationId "in.workindia.nileshdungarwal.workindiaandroid"
minSdkVersion 15
targetSdkVersion 22
versionCode 138
versionName "3.9.3.1"
resConfigs "en", "hi"
//testApplicationId 'in.workindia.nileshdungarwal.workindiaandroid.test'
}
buildTypes {
release {
//versionNameSuffix "-DEV-TEST"
//applicationIdSuffix ".test"
debuggable false
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release_config
}
debug {
useProguard false
versionNameSuffix "-DEBUG"
applicationIdSuffix ".debug"
/*Disable the fabric for debug version and do not update*/
ext.alwaysUpdateBuildId = false
}
}
dexOptions {
javaMaxHeapSize "4g"
jumboMode true
}
buildTypes.debug {
it.buildConfigField 'String', 'BASE_URLS', DEBUG_URLS
it.buildConfigField 'Boolean', 'BRANCH_IO_MODE_IS_LIVE', BRANCH_IO_MODE_DEBUG
it.buildConfigField 'String', 'OFFICE_CONTACT_NO', OFFICE_CONTACT_NO
it.buildConfigField 'String', 'CLIENT_ID', SERVER_DEBUG_CLIENT_ID
it.buildConfigField 'String', 'SECRET_KEYS', SERVER_DEBUG_CLIENT_SECRET
it.buildConfigField 'String', 'GOOGLE_GEOLOCATION_API_KEY', GOOGLE_DEBUG_GEOLOCATION_API_KEY
it.buildConfigField 'String', 'TAG_MANAGER_CONTANER_ID', DEBUG_TAG_MANAGER_CONTANER_ID
it.buildConfigField 'String', 'MQTT_BROKER_USERNAME', MQTT_BROKER_USERNAME
it.buildConfigField 'String', 'MQTT_BROKER_PASSWORD', MQTT_BROKER_PASSWORD
it.buildConfigField 'String', 'POLE_API_KEY', POLE_API_KEY
}
buildTypes.release {
it.buildConfigField 'String', 'BASE_URLS', BASE_URLS
it.buildConfigField 'Boolean', 'BRANCH_IO_MODE_IS_LIVE', BRANCH_IO_MODE_LIVE
it.buildConfigField 'String', 'OFFICE_CONTACT_NO', OFFICE_CONTACT_NO
it.buildConfigField 'String', 'CLIENT_ID', SERVER_RELEASE_CLIENT_ID
it.buildConfigField 'String', 'SECRET_KEYS', SERVER_RELEASE_CLIENT_SECRET
it.buildConfigField 'String', 'GOOGLE_GEOLOCATION_API_KEY', GOOGLE_RELEASE_GEOLOCATION_API_KEY
it.buildConfigField 'String', 'TAG_MANAGER_CONTANER_ID', RELEASE_TAG_MANAGER_CONTANER_ID
it.buildConfigField 'String', 'MQTT_BROKER_USERNAME', MQTT_BROKER_USERNAME
it.buildConfigField 'String', 'MQTT_BROKER_PASSWORD', MQTT_BROKER_PASSWORD
it.buildConfigField 'String', 'POLE_API_KEY', POLE_API_KEY
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
afterEvaluate {
// processDebugGoogleServices.dependsOn switchToDebug
processReleaseGoogleServices.dependsOn switchToRelease
}
task printDependencies << {
configurations.compile.each { println it.name }
}
task switchToDebug(type: Copy) {
description = 'Switches to DEBUG google-services.json'
from "src/debug_work"
include "google-services.json"
into "."
}
task switchToRelease(type: Copy) {
description = 'Switches to RELEASE google-services.json'
from "src/release_work"
include "google-services.json"
into "."
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.1.1') {
exclude module: 'support-v4'
transitive = true
}
compile files('libs/GoogleConversionTrackingSdk-2.2.4.jar')
compile 'me.pushy:sdk:1.0.26'
compile 'io.branch.sdk.android:library:2.+'
compile 'com.facebook.android:facebook-android-sdk:4.19.0'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.mixpanel.android:mixpanel-android:5.+'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-jackson:2.1.0'
compile 'com.edmodo:cropper:1.0.1'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
I would personally say that Use ProGuard
ProGuard will remove the unused Java code. It helps to significantly
reduce the code foot prints.ProGuard is the most popular optimizer for Java bytecode. It makes your Java and Android applications up to 90% smaller and up to 20% faster. ProGuard also provides minimal protection against reverse engineering by obfuscating the names of classes, fields and methods.
Read official guideline about Reduce APK Size .

Categories

Resources