problems in application when changing its package name - android

I am new to application development, it turns out that I have shared the template of an android application.
but it gives me the following problem when I make the change of the packname, (I also make the change in the build.gradle:app , I check the manifest and everything is fine, I have cleaned and rebuilt the project and I have cleared the cache and restarted the android studio ) but it gives me the following problem, once I have compiled the application I pass it to my cell phone but when I open it the application closes and does not open, it does not work.
Note: but if I don't change the packname the application works very well
build.gradle:
`
plugins {
id 'com.android.application'
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
//this to copied
}
def API_KEY = '"' + ApiKey + '"' ?: '"Api Key Not Found"'
def LOGIN_KEY = '"' + LoginKey + '"' ?: '"Login Key Not Found"'
def REG_KEY = '"' + RegKey + '"' ?: '"SignUp Key Not Found"'
def U_PROFILE_KEY = '"' + UprofileKey + '"' ?: '"Profile Key Not Found"'
def FP_KEY = '"' + FpKey + '"' ?: '"Forget P Key Not Found"'
def U_POINTS_KEY = '"' + UpointsKey + '"' ?: '"Update Points Key Not Found"'
def RP_KEY = '"' + RpKey + '"' ?: '"Reset P Key Not Found"'
def UD_KEY = '"' + UdKey + '"' ?: '"Update Points Key Not Found"'
def ADMIN_SETTINGS_KEY = '"' + ASettingsKey + '"' ?: '"Admin Settings Key Not Found"'
def GAME_SETTINGS_KEY = '"' + GSettingsKey + '"' ?: '"Game Settings Key Not Found"'
def REDEEM_SETTINGS_KEY = '"' + RSettingsKey + '"' ?: '"Redeem Settings Key Not Found"'
def APPS_SETTINGS_KEY = '"' + AppsSettingKey + '"' ?: '"Apps Settings Key Not Found"'
def VIDEO_SETTINGS_KEY = '"' + VideoSettingKey + '"' ?: '"Apps Settings Key Not Found"'
def VISIT_SETTINGS_KEY = '"' + VisitSettingKey + '"' ?: '"Visit Settings Key Not Found"'
def STRING = 'String'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
each {type ->
type.buildConfigField STRING, 'ApiKey', API_KEY
}
each {type ->
type.buildConfigField STRING, 'LoginKey', LOGIN_KEY
}
each {type ->
type.buildConfigField STRING, 'RegKey', REG_KEY
}
each {type ->
type.buildConfigField STRING, 'UprofileKey', U_PROFILE_KEY
}
each {type ->
type.buildConfigField STRING, 'FpKey', FP_KEY
}
each {type ->
type.buildConfigField STRING, 'UpointsKey', U_POINTS_KEY
}
each {type ->
type.buildConfigField STRING, 'RpKey', RP_KEY
}
each {type ->
type.buildConfigField STRING, 'UdKey', UD_KEY
}
each {type ->
type.buildConfigField STRING, 'ASettingsKey', ADMIN_SETTINGS_KEY
}
each {type ->
type.buildConfigField STRING, 'GSettingsKey', GAME_SETTINGS_KEY
}
each {type ->
type.buildConfigField STRING, 'RSettingsKey', REDEEM_SETTINGS_KEY
}
each {type ->
type.buildConfigField STRING, 'AppsSettingKey', APPS_SETTINGS_KEY
}
each {type ->
type.buildConfigField STRING, 'VideoSettingKey', VIDEO_SETTINGS_KEY
}
each {type ->
type.buildConfigField STRING, 'VisitSettingKey', VISIT_SETTINGS_KEY
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.4.1' //1.3.0
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' //2.1.2
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('../libs/unity-ads.aar')
testImplementation 'junit:junit:4.13.2' //4.13
implementation 'com.google.android.material:material:1.5.0' //1.4.0
androidTestImplementation 'androidx.test.ext:junit:1.1.3' // 1.1.2
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' //3.3.0
implementation 'com.google.android.gms:play-services-location:19.0.1'
//sceen Size
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
//rootbear
implementation 'com.scottyab:rootbeer-lib:0.1.0'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.onesignal:OneSignal:4.6.0'
//Spin
implementation 'com.github.mmoamenn:LuckyWheel_Android:0.3.0'
//scratch
implementation 'in.codeshuffle.scratchcardlayout:ScratchCardLayout:1.0.8'
//activityLifeCycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//multidex
implementation 'com.android.support:multidex:1.0.3'
//volley
implementation 'com.android.volley:volley:1.2.1'//1.1.1
implementation 'com.google.code.gson:gson:2.8.6'
//:Lottie
implementation "com.airbnb.android:lottie:4.2.0" //3.4.0
//InApp Update
implementation 'com.google.android.play:core:1.10.2'
//Ads Network
implementation 'com.startapp:inapp-sdk:4.9.1'
implementation 'com.applovin:applovin-sdk:11.4.2'
implementation 'com.applovin.mediation:facebook-adapter:6.11.0.2'
implementation 'com.google.android.gms:play-services-ads-identifier'
//glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
//Chrome Tab:
implementation "androidx.browser:browser:1.4.0"
//SweetAlert
implementation 'com.github.f0ris.sweetalert:library:1.5.1'//1.5.1
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.github.ibrahimsn98:SmoothBottomBar:1.7.9'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'applovin-quality-service'
applovin {
apiKey "...."
}
`
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="com.example.app"
tools:ignore="LockedOrientationActivity">
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
tools:node="remove" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.Ad_ID" />
<application
android:name="com.example.app.App"
android:hardwareAccelerated="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:networkSecurityConfig="#xml/network_security_config"
android:theme="#style/AppTheme"
tools:replace="android:icon"
tools:targetApi="n">
<meta-data android:name="applovin.sdk.key"
android:value="#string/APPLOVIN_SDK_KEY"/>
<activity
android:name="com.example.app.activity.VisitActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.VideoActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.InstallActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.AppsActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.GiftCardActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.WatchAndEarnActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.GameLoader"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.GameActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.QuizActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.CaptchaActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.PrivacyActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.SpinActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.ScratchActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.LoginActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.MainActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="false"
android:screenOrientation="portrait"
android:theme="#style/NoActionBar" />
<activity
android:name="com.example.app.activity.SplashActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="#style/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" />
<service
android:name="com.example.app.services.PointsService"
android:enabled="true"
android:exported="false" />
<service
android:name="com.example.app.services.UpdateDateService"
android:enabled="true"
android:exported="false" />
<service
android:name="com.example.app.services.MyFirebaseMessagingService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#mipmap/ic_launcher_round" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorPrimaryDark" />
</application>
</manifest>
`
I change the build.gradle:app , I check the manifest and everything is fine, I have cleaned and rebuilt the project and I have cleared the cache and restarted the android studio. what I hope is that it works with another packname

Related

XMLHttpRequest not firing/calling any [on] callback in react-native Android

react-native v0.63.4 android XMLHttpRequest not calling any [on] callback after sending the request but if I check after in the request data, I find that ready state is DONE and the response status is 200 OK and the data is there but none of the callbacks gets fired.
Here is the code I'm testing with.
var request = new XMLHttpRequest();
request.onabort = () => {
console.warn("ABORTED");
};
request.onerror = () => {
console.warn("ERROR");
};
request.onloadstart = () => {
console.warn("LOAD START");
};
request.onloadend = () => {
console.warn("LOAD END");
};
request.ontimeout = () => {
console.warn("TIMEOUT");
};
request.onload = () => {
console.warn("LOAD");
};
request.onreadystatechange = (e) => {
console.warn("STATE CHANGE", request.status);
if (request.readyState !== 4) {
return;
}
if (request.status === 200) {
console.warn("success", request.responseText);
} else {
console.warn("error");
}
};
request.open("GET", "https://api.github.com/", true);
request.send();
setTimeout(() => {
console.warn(JSON.stringify(request, null, 2)); // this successfully log all the response data.
}, 1000);
My android/app/build.gradle dependencies are.
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation platform('com.google.firebase:firebase-bom:26.4.0')
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
My android/build.gradle is
buildscript {
ext {
RNNKotlinVersion = "1.3.72"
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
playServicesVersion = "17.0.0" // or find latest version
androidMapsUtilsVersion = "2.2.0"
androidXCore = "1.0.2"
}
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath('com.android.tools.build:gradle:4.1.2')
classpath 'com.google.gms:google-services:4.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
finally, my AndroidManifest.xml is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:usesCleartextTraffic="true"
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="mygooglekey"/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<!-- You will also only need to add this uses-library tag -->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
What I'm doing wrong?

Can't send notifications from Parse Server

I am trying to send push notifications from Bitnami Parse Server (3.1.2) hosted on AWS.
I have the server key and the sender ID from firebase in server.js.
Notifications work from the firebase console but not from parse server (neither from the dashbord nor from REST API). It says it's saved but Pushes Sent appear 0 even though I have two installations.
Any ideas?
Puhes Sent 0
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
<application
android:name=".StarterApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DepListActivity" />
<activity android:name=".AngListActivity" />
<activity android:name=".ChangeThePin" />
<activity android:name=".PicActivity" />
<activity android:name=".AddDepActivity" />
<service
android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name="com.parse.fcm.ParseFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
</application>
Project Gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
google()
maven { url "https://jitpack.io" }
}
}
ext {
compileSdkVersion = 24
buildToolsVersion = "24.0.1"
minSdkVersion = 17
targetSdkVersion = 24
}
Module gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.parse.starter"
minSdkVersion 26
targetSdkVersion 28
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 fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'com.parse.bolts:bolts-tasks:1.3.0'
implementation 'com.github.parse-community.Parse-SDK-Android:fcm:1.19.0'
implementation 'com.github.parse-community.Parse-SDK-Android:parse:1.19.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
apply plugin: 'com.google.gms.google-services'
And server.js
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
databaseURI: "",
cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
appId: "",
masterKey: "",
push: {
android: {
senderId: "",
apiKey: ""
}
},
fileKey: "",
serverURL: ""
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);
var port = 1337;
app.listen(port, function() {
console.log('parse-server running on port ' + port);
});
//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
apps: [
{
appName: "My Bitnami Parse API",
appId: "",
masterKey: "",
push: {
android: {
senderId: "",
apiKey: ""
}
},
fileKey: "",
production: true,
serverURL: "
}
],
users: [
{
user: "user",
pass: ""
}
], useEncryptedPasswords: true
});
var allowInsecureHTTP = true;
// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);
var portdash = 4040;
app.listen(portdash, function() {
console.log('parse-dashboard running on port ' + portdash);
});

evollu/react-native-fcm - ClassNotFoundException

My App runs well, but... when it recives a notification from Firebase it Crash.
I think it's happening because my configuration is bad since i had implemented the "react-native-fcm" example.
I getFCMToken() succesfull.
Do you look any error? Do you know why is happening it? Ideas? HelP!!
CONSOLE ERRORS
package.json
"dependencies": {
"firebase": "^4.8.2",
"lodash": "^4.17.4",
"moment": "^2.20.1",
"react": "16.0.0-alpha.12",
"react-firebase-storage-connector": "^1.1.0",
"react-native": "0.47",
"react-native-fbsdk": "^0.7.0",
"react-native-fcm": "^13.3.1",
"react-native-fetch-blob": "^0.10.8",
"react-native-image-picker": "^0.26.7",
"react-native-modal": "^5.0.0",
"react-native-responsive-image": "^2.2.0",
"react-native-side-menu": "^1.1.3",
"react-native-textinput-effects": "^0.4.2",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"slugify": "^1.2.9"
},
app/build.gradlew
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.reactnavigationdrawer"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:+"
compile "com.facebook.react:react-native:+" // From node_modules
compile(project(':react-native-fbsdk')) {
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
}
compile('com.facebook.android:facebook-android-sdk:4.22.1')
compile ("com.google.android.gms:play-services-base:11.2.0") {
force = true;
}
compile ('com.google.firebase:firebase-core:11.2.0') {
force = true;
}
compile ('com.google.firebase:firebase-auth:11.2.0') {
force = true;
}
compile (project(':react-native-fcm')){
exclude group: "com.google.firebase"
}
compile ("com.google.android.gms:play-services-gcm:11.2.0") {
force = true;
}
compile project(':react-native-vector-icons')
compile project(':react-native-fetch-blob')
compile project(':react-native-image-picker')
}
apply plugin: 'com.google.gms.google-services'
build.gradlew
dependencies {
classpath 'com.android.tools.build:gradle:2.2.+' // <- USE 2.2.+ version
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
MainActivity.java
package com.reactnavigationdrawer;
import com.facebook.react.ReactActivity;
import android.content.Intent;
public class MainActivity extends ReactActivity {
#Override
public void onNewIntent (Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
#Override
protected String getMainComponentName() {
return "reactnavigationdrawer";
}
}
MainApplication.java
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new ImagePickerPackage(),
new RNFetchBlobPackage(),
new FIRMessagingPackage(),
new FBSDKPackage(mCallbackManager)
);
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnavigationdrawer"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#drawable/ic_launcher"/>
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
if you need more information you'll tell me!
the error reads ...
unable to resolve superclass of com.evullu.react.fcm.MessagingService
this means either reference in the Mainfest.xml is wrongful and / or the referenced class com.evullu.react.fcm.MessagingService does not exist. it might probably be rather called com.reactnavigationdrawer.MessagingService (or alike) and there's no need to compile the obsoleted package play-services-gcm either.
better add a dependency for com.google.firebase:firebase-messaging:11.8.0 ...which should contain the superclass of com.evullu.react.fcm.MessagingService, which cannot be resolved. you can check with ./gradlew app:dependencies | grep firebase whether it is present.
that file build.gradlew should be called build.gradle and Android Studio might complain about outdated versions ...meanwhile it's com.android.tools.build:gradle:3.0.1 & com.google.gms:google-services:3.1.2. that force = true; also seems useless in that context, at least don't understand what it shall do there, see ResolutionStrategy.

Android Studio Canary 2.4 errors

I have update Android Studio to the new Canary version, and I updated my gradle file. When I launch my app through run, I get the following error:
Process: io.github.siddharthvenu.saltanalysis, PID: 23244
java.lang.SecurityException: Signature check failed for io.github.siddharthvenu.saltanalysis
at android.os.Parcel.readException(Parcel.java:1915)
at android.os.Parcel.readException(Parcel.java:1861)
at com.google.android.gms.common.internal.zzv$zza$zza.zza(Unknown Source:41)
at com.google.android.gms.common.internal.zzf.zza(Unknown Source:0)
at com.google.android.gms.internal.zzzf$zzc.zzxQ(Unknown Source:0)
at com.google.android.gms.internal.zzzf$zzf.run(Unknown Source:0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.internal.zzabx.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
Edit: I found that the above error is caused due to AdView of Android. Somehow including ads in my app makes it crash.
I thought this was maybe because I didn't sign the apk, so I signed it (debug), and then tried to install it using adb install command. I got the following output:
Failed to install alpha_test_006.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
My AndroidManifest:
<?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="io.github.siddharthvenu.saltanalysis">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="#mipmap/ic_material_chemical"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup">
<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RadicalListActivity"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.TranslucentActionBar"
android:screenOrientation="sensorPortrait"
tools:targetApi="jelly_bean" />
<activity
android:name=".DisplayRadicalActivity"
android:parentActivityName=".RadicalListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
tools:targetApi="jelly_bean" />
<activity
android:name=".GroupSeparationActivity"
android:parentActivityName=".HomeActivity"
android:screenOrientation="sensorLandscape"
tools:targetApi="jelly_bean" />
<activity
android:name=".LongProcedureActivity"
android:label="Long Procedure"
tools:targetApi="jelly_bean"/>
</application>
</manifest>
My build.gradle:app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-O'
buildToolsVersion '26.0.0-rc1'
def versionPropsFile = file('version.properties')
def code = 1
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
List<String> runTasks = gradle.startParameter.getTaskNames();
def value = 0
for (String item : runTasks)
if (item.contains("assembleRelease")) {
value = 1
}
code = versionProps['VERSION_CODE'].toInteger() + value
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
applicationId "io.github.siddharthvenu.saltanalysis"
minSdkVersion 15
targetSdkVersion 'O'
versionCode code
versionName "1.0 Alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
} else {
throw new FileNotFoundException("Could not read version.properties!")
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
def str_ver
if ((int) (code / 100) != 0) {
str_ver = String.valueOf(code)
} else if ((int) (code / 10) != 0) {
str_ver = "0" + String.valueOf(code)
} else {
str_ver = "00" + String.valueOf(code)
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent,
output.outputFile.name.replace(output.outputFile.name, "alpha_test_" + str_ver + ".apk")
)
}
}
}
}
}
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.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
I found out the reason for the SecurityException generated in the first case. It was due to including an AdViewin my code. I tried to comment it out, and it worked. I suspected this because only activities which contained the AdView's crashed.
The adb install issue still persists though

FirebaseInstanceIdService getToken returning null

Im trying to add FCM notifications to my app, but for some reason
FirebaseInstanceId.getInstance().getToken();
is returning null.
Since im not getting any stacktrace my best guess is that FirebaseInstanceIdService is not working
Google Play Services version: 9.6.1
Firebase-messaging version : 9.6.1
added json config file from FirebaseConsole (Tried single file with 2 clients inside it, one for debug and one for release build) and 2 files each for respective build
Iw applied google services plugin at the bottom of my modules gradle script
Included google services in projects root gradle script
Created 2 services from the officail docs:
public class MyFirebaseInsanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
#Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
PreferencesHelper.putSharedPreferencesString(Constants.User.PUSH_NOTIFICATIONS, refreshedToken);
Log.e("TOKEN", "Token: " + FirebaseInstanceId.getInstance().getToken());
}
}
And the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.fc.test">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="fctest"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="${appName}${appNameSuffix}"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:node="replace">
<service
android:name="com.fc.test.MyFirebaseInsanceIDService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service
android:name="com.fc.test.MyFirebaseMessagingService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<activity
android:name="com.fc.test.view.splash.Splash"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.CenterAnimation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
root Gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/drummer-aidan/maven" }
maven { url "https://maven.fabric.io/public" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://jitpack.io" }
}
}
ext {
buildToolsVersion = '24.0.1'
compileSdkVersion = 24
minSdkVersion = 15
targetSdkVersion = 24
supportLibraryVersion = '24.2.1'
}
and the main part of the modules Gradle
dependencies {
final PLAY_SERVICES_VERSION = '9.6.1'
final SUPPORT_LIBRARY_VERSION = '24.2.1'
final RETROFIT_VERSION = '2.1.0'
final DAGGER_VERSION = '2.5'
final DEXMAKER_VERSION = '1.4'
final HAMCREST_VERSION = '1.3'
final ESPRESSO_VERSION = '2.2.1'
final RUNNER_VERSION = '0.4'
final BUTTERKNIFE_VERSION = '8.1.0'
def daggerCompiler = "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
def jUnit = "junit:junit:4.12"
def mockito = "org.mockito:mockito-core:1.10.19"
// App Dependencies
compile "com.google.android.gms:play-services-gcm:$PLAY_SERVICES_VERSION"
compile "com.google.firebase:firebase-messaging:$PLAY_SERVICES_VERSION"
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services
Note that im using tools:node="replace" in my root application tag.
Is it possible that FirebaseInstanceIdService is not added to the manifest since it has the same intent filter as mine FirebaseInstanceService and thus not being called?
So my question here would be is there something wrong it the official docs or in my implementation that should cause the Instance token to be null?
After digging up thru old implementations of FCM and generated manifests, I can now say that manifest merger is the problem.
Solution for this problem is adding these classes to the apps manifest manualy
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.fc.debug" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />
<!--
-->
<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.fc.debug.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
While I was doing the migration I had a problem, it was that I didn't receive any Notification. To solve this and If you have your GCM working, don't forget to include your sender ID when you get the Firebase Token. To consult this ID you have to navigate to your Firebase project and click Project Name. Click the Setting icon and select "Project Setting" menu Select "Could Messaging" tab and use sender ID on the page.
And when says to code this:
token = FirebaseInstanceId.getInstance().getToken();
You have to use this:
token = FirebaseInstanceId.getInstance().getToken("YOUR_SENDER_ID", "FCM");
It works for me, I hope this helps you ;)
This worked for me:
String token = FirebaseInstanceId.getInstance().getInstanceId().getResult().getToken();
First genarate "google-services.json" and Add this file in your android studio Like this projectFolder/APP/google-services.json
Add classpath to top level build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Add following plugin and dependencies in app’s build.gradle
apply plugin: 'com.google.gms.google-services'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
}
Add following Firebase services in your java files
FirebaseIDService.java
package com.galleonsoft.firebase.push;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
public class FirebaseIDService extends FirebaseInstanceIdService {
private static final String TAG = "FirebaseIDService";
#Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// TODO: Implement this method to send any registration to your app's servers.
sendRegistrationToServer(refreshedToken);
}
private void sendRegistrationToServer(String token) {
// Add custom implementation, as needed.
}
}
MyFirebaseMessagingService.java
package com.galleonsoft.firebase.push;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class MyFirebaseMEssagingService extends FirebaseMessagingService {
private static final String TAG = "FCM Service";
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO: Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated.
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
}
}
Add service in your AndroidMainifest.xml file
<service android:name=".MyFirebaseMEssagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".FirebaseIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>

Categories

Resources