Why can I see server response in my signed apk android? - android

I generated a signed apk using a .jks file for release.
It got uploaded on playstore for beta testing also. But if I use the app with my andorid-studio I can see the server responses in my log-cat which should not be the case as far as I know.
When I generate the apk, i can see the build type release
and my build.gradle of module is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "PACKAGE_NAME"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/menu']
java.srcDirs = ['src/main/java', 'src/main/java/2', 'src/main/java/PACKAGE_NAME/Models']
}
}
productFlavors {
}
}
Can anyone explain?

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.
You can use your logs like below
public class AppLog {
public static void info(String tag, String message) {
if (BuildConfig.DEBUG) {
Log.i(tag, message);
}
}
}
Refer : https://developer.android.com/reference/android/util/Log.html

Related

How to configure product flavor in new gradle

I am configuring paid and free version of my app and I got below error. I already configure same before android 3 without problem.
How to fixe it please ?
Gradle script
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "capstone.nanodegree.udacity.com.mypodcast"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
//flavorDimensions "default"
flavorDimensions "free", "paid"
productFlavors {
free {
applicationId "capstone.nanodegree.udacity.com.mypodcast.free"
dimension "free"
}
paid {
applicationId "capstone.nanodegree.udacity.com.mypodcast.paid"
dimension "paid"
}
}
}
def AAVersion = '4.4.0'
def GLIDEVersion = '4.3.1'
def supportVersion = '26.1.0'
Check that there's entries for both packages in your google-services.json .....also, and this might be separate issue, I believe you should only have to define one dimension (both your flavors would have same dimension value)
I am using Flavors same as you, I'll remove 2 of my flavors and rename for simplicity comparisons:
compileSdkVersion 26
buildToolsVersion googleBuildTools
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.myapp"
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
releaseMyApp {
storeFile file("$projectDir/../myappkeystore.jks")
storePassword System.getenv('MYAPP_STORE_PASSWORD')
keyAlias System.getenv('MYAPP_KEY_ALIAS')
keyPassword System.getenv('MYAPP_KEY_PASSWORD')
}
}
productFlavors {
myapp {
applicationId "com.myApp.one"
buildConfigField "String", "SERVER_URL", '"https://api.myappone.com"'
versionCode 24
versionName "1.18"
minSdkVersion 21
}
myappStaging {
applicationId "com.myapp.one.staging"
buildConfigField "String", "SERVER_URL", '"https://stg.api.myappone.com"'
versionCode 24
versionName "1.18"
minSdkVersion 21
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
productFlavors.myapp.signingConfig signingConfigs.releaseMyapp
productFlavors.myappStaging.signingConfig signingConfigs.releaseMyapp
}
}
without issues, but i'll post in case there is something different that you notice that I didn't, but your error is probably related to your firebase json. You can use the same json file for all your flavors, you just need a client section for each application identifier. which you can create online through firebase portal.
I made the mistake of making individual firebase json files for each flavor and later figured out I didn't need to do that as they were all identical with all clients in them.
Originally I only used flavors for two different application types, but later had to make flavors for staging as well to support PUSH in multiple environments. Goodluck. Hopefully that helps, but I'm guessing you need to fix your firebase json file.

Gradle: sourceSets not working as expected

Gradle: sourceSets not working as expected.
Here is my code:
android {
...
defaultConfig {
applicationId "com.firsthash.smartyoutubetv2"
minSdkVersion 14
targetSdkVersion 25
versionCode 111
versionName "6.8.39"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res-exoplayer', 'src/main/res-xwalk', 'src/main/res-webview']
}
debug {
res.srcDirs = ['src/main/res', 'src/main/res-exoplayer', 'src/main/res-xwalk', 'src/main/res-webview']
}
}
productFlavors {
full {
}
beta {
applicationIdSuffix ".beta"
}
}
}
The problem. Everything goes ok until I try to do an update of any project's layout file. All changes that I've made didn't reflected on the final application. I figured out that to obtain right behavior I need to manually delete project's 'build' directory. This directory contains cached build files. Such happens when I built apk using 'gradle: installDebug task' or Android Studio internal build system.
UPD: best workaround that could find is to use flavor dimensions: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-flavor-variants

Getting gradle exception after updating to com.google.gms:google-services:3.0.0

Yesterday, I updated my google services gradle plugin to this:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
After that, I am getting below error in my devDebug flavour build:
Error:org.gradle.api.GradleException: No matching client found for package name 'com.example.android.dev'
Here are the relevant part of my app level build.gradle file:
defaultConfig {
applicationId 'com.example.android'
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 24
versionCode 47
versionName "1.3.2"
signingConfig signingConfigs.myConfig
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
applicationIdSuffix = ".dev"
resValue "string", "app_name", "example-debug"
}
release {
minifyEnabled false
shrinkResources false
resValue "string", "app_name", "example"
signingConfig signingConfigs.myConfig
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 16
}
}
This error does not come in my prodRelease product flavour build. How can I resolve it?
In your debug build type you are using this package:
debug {
applicationIdSuffix = ".dev"
}
This message
No matching client found for package name 'com.example.android.dev'
means that your google-services.json doesn't contain this package.
Follow these steps:
Go to Firebase console
add another android app registering also this package
Export again the google-services.json
Re-register your key on console.developers
Finally fixed the issue.
The trick is to add another app to the Firebase console with the debug package name and debug SHA1 fingerprint.
Doing this essentially creates 2 apps but the google-services.json file downloaded from any app contains information about both apps.

Android gradle product flavors with wearable apps

I'm adding a wearable component to an existing app which uses product flavors in the gradle build to build multiple versions of the app.
I know the package names / application Id's need to match between the mobile and wearable builds, but do I just need to copy the
productFlavors
signingConfigs
buildTypes
from my main mobile app. I'm not quite sure if all of this is needed to get things working or not.
The productFlavors no, unless you are going to do something specific for the wear app with a particular flavor.
The signingConfigs and buildTypes you should copy, the wear app definitely needs to be signed as well. You may adapt the buildType for wear such is enable/disable minify it you want from the main app.
Here's a portion of my own mobile and wear build configs
Mobile
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.codechimp.qrwear"
minSdkVersion 18
targetSdkVersion 20
versionCode 26
versionName "1.20"
}
productFlavors {
prod {
}
dev {
versionName = android.defaultConfig.versionName + " dev"
}
}
signingConfigs { release }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
Wear
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.codechimp.qrwear"
minSdkVersion 20
targetSdkVersion 20
versionCode 26
versionName "1.20"
}
signingConfigs { release }
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}

Duplicate files in Android build - but I can't exclude the guilty file?

I'm encountering this duplicate file error when building an app on Android Studio with Gradle:
Error:duplicate files during packaging of APK /Users/lgorse/AndroidStudioProjects/Androidhive-test/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: lib/armeabi/libavcodec-55.so
Origin 1: /Users/lgorse/AndroidStudioProjects/Androidhive-test/app/build/intermediates/exploded-aar/io.cine/cineio-broadcast-android-sdk/0.0.9/jni/armeabi/libavcodec-55.so
Origin 2: /Users/lgorse/AndroidStudioProjects/Androidhive-test/app/build/intermediates/exploded-aar/Androidhive-test/kickflip-android-sdk/unspecified/jni/armeabi/libavcodec-55.so
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'lib/armeabi/libavcodec-55.so'
}
}
I already implemented the solution in this answer. However the problem persists.
I've actually tried to exlcude the package in all 3 build.gradles (the app, and the two modules for the dependencies).
Here is an example of how it looks like on the app build.gradle:
android {
compileSdkVersion 21
buildToolsVersion '21.1'
defaultConfig {
applicationId "com.example.lgorse.androidhive_test"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
debuggable true
}
}
packagingOptions {
exclude 'lib/armeabi/libavcodec-55.so'
}
}

Categories

Resources