on adding targetSDKVersion app is not working - android

I have a step counter Andriod app, I have to upload it on playstore and it's not working with targetSDKversion defined as playstore needs a API level 29+
and this default API is 28 (Playstore Console told)
this is the /build.gralde file
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.4'
if (rootProject.ext.has("gradle_classpath")) {
classpath rootProject.ext.gradle_classpath
} else {
logger.warn('classpath not found in rootProject')
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:4.3.4'
}
}
}
allprojects {
repositories {
jcenter()
maven{url "https://jitpack.io"}
google()
mavenCentral()
}
}
apply plugin: 'com.android.application'
android {
if (rootProject.ext.has("compileSdkVersion")) {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
} else {
logger.warn('compileSdkVersion not found in rootProject')
compileSdkVersion = 30
buildToolsVersion = "30.0.3"
}
defaultConfig {
applicationId "com.j4velin.pedometer"
minSdkVersion 21
multiDexEnabled true
}
flavorDimensions "main"
productFlavors {
fdroid {
dimension "main"
}
}
lintOptions{
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
buildTypes {
release {
signingConfig signingConfigs.release
zipAlignEnabled true
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
debuggable true
signingConfig signingConfigs.release
zipAlignEnabled true
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 30
buildToolsVersion '30.0.3'
}
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.github.j4velin.colorpicker:colorpicker:1.20.6'
implementation 'com.github.j4velin.EazeGraph:EazeGraph:1.0.3'
implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.github.Shashank02051997:FancyToast-Android:0.1.8'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.facebook.shimmer:shimmer:0.5.0'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation platform('com.google.firebase:firebase-bom:26.3.0')
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.6.0'
playImplementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation 'org.jsoup:jsoup:1.10.2'
implementation 'com.ogaclejapan.smarttablayout:library:2.0.0#aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:2.0.0#aar'
}
apply plugin: 'com.google.gms.google-services'
This is working and app is working fine and counting steps
but when I add targetSDKVersion
defaultConfig {
applicationId "com.j4velin.pedometer"
minSdkVersion 21
multiDexEnabled true
targetSdkVersion 30 //APP STOPS COUNTING STEPS
}
This is my AndroidManifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.shubham.pedo"
android:versionCode="1"
android:versionName="1.0.0">
<uses-feature
android:name="android.hardware.sensor.stepcounter"
android:required="true" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="android.permission.WAKE_LOCK" android:maxSdkVersion="30" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault.Light.DarkActionBar"
tools:replace="label">
<activity
android:name=".AboutActivity"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
android:exported="true"/>
<activity
android:name=".PEDOMETER.Google_Sign_In"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light"/>
<receiver android:name=".PEDOMETER.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".PEDOMETER.AppUpdatedReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<service android:name=".PEDOMETER.SensorListener" />
<service
android:name=".PEDOMETER.widget.DashClock"
android:permission="com.google.android.apps.dashclock.permission.READ_EXTENSION_DATA">
<intent-filter>
<action android:name="com.google.android.apps.dashclock.Extension" />
</intent-filter>
<meta-data
android:name="protocolVersion"
android:value="2" />
<meta-data
android:name="worldReadable"
android:value="true" />
<meta-data
android:name="description"
android:value="Displays the steps taken today" />
</service>
<activity
android:name=".PEDOMETER.widget.WidgetConfig"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Holo.Dialog.NoActionBar">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver android:name=".PEDOMETER.widget.Widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<service
android:name=".PEDOMETER.widget.WidgetUpdateService"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
</application>
</manifest>
Everything is working fine without adding targetSDKVersion, with adding this playstore accepts release apk but that stops counting the steps of User

Related

I am getting blank screen after integrating google maps api in my android application

I tried integrating google maps API in my android application but I keep getting a blank grey screen. Attaching manifest and build.gradle file. The activity file contains the default code that comes while creating a google maps activity. You can clearly see this in manifest file.
I have mentioned the API key. I think the issue lies in dependencies, I might not have included every library that requires in order to run the app but I am not able to figure it out.
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mppolice">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MPPolice">
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow the directions here:
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
<activity
android:name=".NearbyPolice"
android:exported="false"/>
<activity
android:name=".More"
android:exported="false" />
<activity
android:name=".WomanHelpline"
android:exported="false" />
<activity
android:name=".Statistics"
android:exported="false" />
<activity
android:name=".MissingPerson"
android:exported="false" />
<activity
android:name=".NearbyOffenders"
android:exported="false" />
<activity
android:name=".Contacts"
android:exported="false" />
<activity
android:name=".CrimeReport"
android:exported="false" />
<activity
android:name=".PasswordActivity"
android:exported="false" />
<activity
android:name=".AuthScreen"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="false"
android:label="#string/title_activity_main"
android:theme="#style/Theme.MPPolice.NoActionBar" />
<activity
android:name=".SplashScreen"
android:exported="true"
android:theme="#style/Theme.MPPolice.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdk 31
defaultConfig {
applicationId "com.example.mppolice"
minSdk 21
targetSdk 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_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation "androidx.cardview:cardview:1.0.0"
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
implementation 'com.google.firebase:firebase-auth:21.0.7'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:30.3.1')
implementation 'com.google.firebase:firebase-analytics'
}

Why my emulator is throwing me the error, missing system image?

Well, actually, I am a newbie to android. I have been trying to develop an app that has google maps, and everything was going fine until today when I got this error from the emulator.
Here are some files in case it may be helpful.
Manifest XML file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.uaproject">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.UAProject">
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".Hotels"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
<activity
android:name=".NoteEditorActivity"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<activity
android:name=".AboutApp"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".Copyrights"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".ToAboutBayanOlgey"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".ToAboutUs"
android:exported="true"
android:parentActivityName=".Menu" />
<activity
android:name=".Menu"
android:exported="true"
android:parentActivityName=".HomeScreen" />
<activity
android:name=".HomeScreen"
android:exported="true" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle-app level
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.uaproject"
minSdk 19
targetSdk 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
}
}
dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.github.smarteist:autoimageslider:1.3.9'
implementation 'com.google.android.material:material:<version>'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
build.gradle-root level
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
PS: By the way, if you guys have time, could you please guide me on how to add google maps to an already-created fragment(for example, my fragment is the one of a bottom navigation). I have been searching but all I tried did not work for some reason. Or just a link to the valid way would do because there seemed to be many obsolete approaches to this as well, which we beginners cannot really discern.

Android App Crash when One Signal Notification sent

My App Crash every time I send a One Signal Push notification.
note: firebase has no issue also one signal inApp message working fine. also, Receive push notification of one signal with crash
with firebase, it has no issue but I want to use one signal I tries so many things but not working
Here is my error from logcat
The Error
2021-07-20 22:10:37.431 14322-16493/###### E/AndroidRuntime: FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
Process: #######, PID: 14322
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.messaging.RemoteMessage$Notification.getTitle()' on a null object reference
at ######.MyFirebaseMessagingService.onMessageReceived(MyFirebaseMessagingService.java:17)
at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(com.google.firebase:firebase-messaging##22.0.0:13)
at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging##22.0.0:8)
at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging##22.0.0:3)
at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging##22.0.0:3)
at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging##22.0.0:1)
at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement##17.5.0:6)
at java.lang.Thread.run(Thread.java:764)
Here are my codes
I have added both the firebase class and one signal class in the manifest file
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="######"
android:installLocation="auto">
<!--
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
-->
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true" />
<application
android:name=".AppController"
android:allowBackup="false"
>
<activity android:name=".activity.MainActivity" />
<activity
android:name=".activity.SplashScreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity
android:name=".activity.SettingActivity"
android:label=""
android:theme="#style/Theme.AppCompat.Light.Dialog" />
<activity
android:name=".activity.InstructionActivity"
android:label="My Custom AppIntro"
android:theme="#style/Theme.Intro" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_app_id" />
<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" />
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/notification_yellow" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorAccent" />
<meta-data android:name="com.onesignal.NotificationAccentColor.DEFAULT"
android:value="#FFCC00" />
<activity android:name=".activity.ReviewActivity" />
<activity android:name=".activity.BookmarkList" />
<activity android:name=".AboutUs" />
<activity android:name=".About" />
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
Build. Gradle (app)
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "#########"
minSdkVersion 17
targetSdkVersion 30
versionCode 1
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
archivesBaseName = "Offline Quiz"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'com.google.firebase:firebase-inappmessaging-display:20.0.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.android.gms:play-services-ads:19.4.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.google.android.gms:play-services-games:21.0.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.github.AppIntro:AppIntro:6.1.0'
implementation 'io.github.dreierf:material-intro-screen:0.0.6'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
// One signal SDK
implementation 'com.onesignal:OneSignal:4.4.1'
// firebase
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
}
apply plugin: 'com.google.gms.google-services'
Build.Gradle(project)
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.google.gms:google-services:4.3.8'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.13.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
google()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Firebase class
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import org.jetbrains.annotations.NotNull;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived( RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
getFirebaseMessage(remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody());
}
public void getFirebaseMessage (String title, String msg)
{
NotificationCompat.Builder builder = new NotificationCompat.Builder(this,"myFirebasechannel")
.setSmallIcon(R.drawable.ic_notification_test)
.setContentTitle(title)
.setContentText(msg)
.setAutoCancel(true);
NotificationManagerCompat manger=NotificationManagerCompat.from(this);
manger.notify(101,builder.build());
}
}
This fixed the problem for me: https://stackoverflow.com/a/45268868/9878385
I had to add implementation "com.google.firebase:firebase-core:16.0.1" or similar into app/build.gradle

Android Studio Installs Apk More Than Once

I developed an app and delete Junit tests implementation from my gradle file to remove the tests package. I'm not sure if was after that, but since, android studio doesn't install one, but four times my app, all are the same.
This is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="braziliancard.veraodedescontos_lojista">
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:theme="#style/AppTheme"
android:allowBackup="true"
android:debuggable="true"
tools:ignore="HardcodedDebugMode">
<activity android:name=".SplashScreenActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginLojista" android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".utils.ToolbarCaptureActivity" android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
This is a screenshot of what is happening:
this is my gradle.file (app) file:
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
jcenter()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
}
}
apply plugin: 'com.android.application'
android {
//compileSdkVersion project.androidTargetSdk
compileSdkVersion 26
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
def validConfig
def keystoreFile
def keystorePassword
def keystoreAlias
try {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
keystoreFile = properties.getProperty('keystore.file')
keystorePassword = properties.getProperty('keystore.password')
keystoreAlias = properties.getProperty('keystore.alias')
validConfig = keystoreFile != null && keystorePassword != null && keystoreAlias != null;
} catch (error) {
validConfig = false
}
if (validConfig) {
System.out.println("Release signing configured with " + keystoreFile)
signingConfigs {
release {
storeFile project.rootProject.file(keystoreFile)
storePassword keystorePassword
keyAlias keystoreAlias
keyPassword keystorePassword
}
}
} else {
System.out.println("Specify keystore.file, keystore.alias and keystore.password in local.properties to enable release signing.")
}
buildTypes {
release {
if (validConfig) {
signingConfig signingConfigs.release
}
debug {
debuggable true
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26'
implementation 'com.android.support:preference-v14:26+'
implementation 'com.android.support:support-v13:26+'
implementation 'com.burgstaller:okhttp-digest:1.17'
implementation 'net.sourceforge.jtds:jtds:1.3.1'
implementation 'com.sunmi:sunmiui:latest.release'
// implementation 'javax.mail:1.4.7'
implementation 'com.android.support:appcompat-v7:26+'
implementation 'com.android.support:design:26+'
implementation 'com.android.support:recyclerview-v7:26+'
implementation 'com.sun.mail:android-mail:1.6.2'
implementation 'com.sun.mail:android-activation:1.6.2'
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5'
// releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
implementation files('/lib/commons-email-1.5.jar')
implementation project(':zxing-android-embedded')
implementation files('/lib/additionnal.jar')
}
I copied the java folder, the layouts, and the AndroidManifest into another app who was working fine, but the android studio still install more than one time the app.
i guess is something about android manifest or gradle, but i have no idea of what. some tips?
You have the same number of shortcut as your number of launcher activities.
In most of the case, only one is needed
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="braziliancard.veraodedescontos_lojista">
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:theme="#style/AppTheme"
android:allowBackup="true"
android:debuggable="true"
tools:ignore="HardcodedDebugMode">
<activity android:name=".SplashScreenActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".LoginLojista" android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".utils.ToolbarCaptureActivity" android:theme="#style/AppTheme.NoActionBar"/>
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>

label app_name changes to library label in Android

In my app, I use a library from an aar file. lets say library.aar
My app is called, "Awsome app", so I have a string value:
<string name="app_name" translatable="false">Awsome app</string>
But when I compile the app, the name in the mobilephone is "SDK", where this label is from the library.aar
strings.xml:
<string name="app_name" translatable="false">Awsome App</string>
Is there any way to avoid the library change my app name?
== EDIT ==
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx.xxx.AwsomeApp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="xxx.xxx.AwsomeApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<meta-data
android:name="DATABASE"
android:value="app.db" />
<meta-data
android:name="VERSION"
android:value="1" />
<meta-data
android:name="QUERY_LOG"
android:value="false" />
<meta-data
android:name="DOMAIN_PACKAGE_NAME"
android:value="xxx.xxx.AwsomeApp" />
<activity
android:name="xxx.xxx.AwsomeApp.MainActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" />
<activity
android:name="xxx.xxx.AwsomeApp.SplashActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="xxx.xxx.AwsomeApp.LegalActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" />
<activity
android:name="xxx.xxx.AwsomeApp.LoginActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" />
<activity
android:name="xxx.xxx.AwsomeApp.QuizActivity"
android:label="#string/title_activity_quiz" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</application>
</manifest>
I add the gradle file to:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.20.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion '23.0.3'
productFlavors{
vanilla {
applicationId "xxx.xxx.AwsomeApp"
buildConfigField 'String','HOST_API', '"awsomeURL"'
}
bsa {
applicationId "xxx.xxx.AwsomeApp.bsa"
buildConfigField 'String','HOST_API', '"awsomeURL"'
}
}
defaultConfig {
applicationId "xxx.xxx.AwsomeApp"
minSdkVersion 15
targetSdkVersion 25
versionCode 8
versionName "1.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
dependencies {
androidTestCompile 'com.android.support:support-annotations:25.0.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.github.satyan:sugar:1.4'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.problematiclibrary.sdk:sdk-release#aar' <<--- here is the libray (I dont put the real name, cause if from work)
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
}
Try to put App name direct as String in application tag. and show the output.
<application
android:name="xxx.xxx.AwsomeApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="Awsome App"
android:supportsRtl="true"
android:theme="#style/AppTheme">
Let me know after try this...

Categories

Resources