XMLHttpRequest not firing/calling any [on] callback in react-native Android - 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?

Related

Android: FirebaseMessaging.getToken() on a null object reference

I'm having problems using onesignal. I tried to use onesignal on another project and it worked but on this project i get error. I guess some libraries are causing this problem.
App Gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'androidx.navigation.safeargs'
id 'kotlin-kapt'
id 'com.google.gms.google-services'
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
buildFeatures {
viewBinding true
}
defaultConfig {
applicationId "com.ersincoskun.focusapp"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8' }
}
dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('libs\\YouTubeAndroidPlayerApi.jar')
def nav_version = "2.3.4"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.4.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.AppIntro:AppIntro:6.1.0'
implementation 'com.akexorcist:round-corner-progress-bar:2.1.1'
implementation 'it.xabaras.android:recyclerview-swipedecorator:1.2.3'
def room_version = "2.3.0"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
def lifecycle_version = "2.3.1"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation 'androidx.activity:activity-ktx:1.3.1'
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
//retrofit
def retrofitVersion = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation 'me.tankery.lib:circularSeekBar:1.3.0'
implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.4.0-alpha01"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
implementation 'com.eightbitlab:blurview:1.6.6'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.MdFarhanRaja:SearchableSpinner:2.0'
implementation platform('com.google.firebase:firebase-bom:28.3.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
implementation "com.google.firebase:firebase-iid"}
Top Level Gradle
buildscript {
ext.kotlin_version = "1.5.10"
repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.9'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
def nav_version = "2.3.4"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
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.ersincoskun.focusapp">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<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.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission
android:name="android.permission.INTERNAL_SYSTEM_WINDOW"
tools:ignore="ProtectedPermissions" />
<application
android:name=".MyApplicationClass"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="Focused Pupa"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.FocusApp"
android:usesCleartextTraffic="true"
tools:node="replace">
<activity
android:name="com.ersincoskun.focusapp.view.fragments.watchvideo.FullScreenVideoActivity"
android:screenOrientation="sensorLandscape">
</activity>
<service android:name="com.ersincoskun.focusapp.service.SessionService" />
<activity android:name="com.ersincoskun.focusapp.view.activities.NotificationActivity" />
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="#style/Base.Theme.AppCompat" />
<activity
android:name="com.ersincoskun.focusapp.view.activities.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.ersincoskun.focusapp.view.activities.RegisterActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity android:name="com.ersincoskun.focusapp.view.activities.IntroActivity" />
<activity
android:name="com.ersincoskun.focusapp.view.activities.SplashScreen"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_path" />
</provider>
</application>
Application Class
import android.app.Application
import com.onesignal.OneSignal
import androidx.work.Configuration
class MyApplicationClass : Application(),Configuration.Provider {
private val ONESIGNAL_APP_ID = "xxxxxxxxxxxxxxxxxxxxxxx"
override fun onCreate() {
super.onCreate()
// Enable verbose OneSignal logging to debug issues if needed.
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE)
// OneSignal Initialization
OneSignal.initWithContext(this)
OneSignal.setAppId(ONESIGNAL_APP_ID)
}
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO)
.build()
}
Stacktrace
i get these errors what should i do to resolve please help me
my stacktrace
Try initialializing FirebaseApp in your application class to fix this issue.
Application Class
import android.app.Application
import com.onesignal.OneSignal
import androidx.work.Configuration
class MyApplicationClass : Application(),Configuration.Provider {
private val ONESIGNAL_APP_ID = "xxxxxxxxxxxxxxxxxxxxxxx"
override fun onCreate() {
super.onCreate()
// Add this line
FirebaseApp.initializeApp(this)
// Enable verbose OneSignal logging to debug issues if needed.
OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE)
// OneSignal Initialization
OneSignal.initWithContext(this)
OneSignal.setAppId(ONESIGNAL_APP_ID)
}
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO)
.build()
}
Hope this helped you out. Happy Coding! :)

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);
});

Google Play services error Execution failed for task ':transformClassesWithJarMergingForRelease'

Im trying to implement Google play services into my game. Also, im using AdInCube plugin., which works fine, but now i have two AndroidManifest files. Maybe thats the problem? I already fixed one error (https://github.com/playgameservices/play-games-plugin-for-unity/issues/2028) by reimporting package and force resolve. After this, i cant build my game. I got an error:
What went wrong:
Execution failed for task ':transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/
GoogleServices Manifest:
<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by the Google Play Games plugin for Unity
Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.games.mainlibproj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application>
<!-- The space in these forces it to be interpreted as a string vs. int -->
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="\u003402577249840" />
<!-- Keep track of which plugin is being used -->
<meta-data android:name="com.google.android.gms.games.unityVersion"
android:value="\u0030.9.53" />
<activity android:name="com.google.games.bridge.NativeBridgeActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>
AdInCube Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.****.snake.101"
android:installLocation="preferExternal"
android:versionCode="9"
android:versionName="1.1.7">
<uses-permission android:name="com.android.vending.BILLING" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/UnityThemeSelector">
<activity
android:name="com.unity3d.player.UnityPlayerActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="unityplayer.UnityActivity"
android:value="true" />
</activity>
</application>
</manifest>
Gradle:
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.adincube.sdk:AdinCube-Unity-3626ebe:2.3.1#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
**DEPS**
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion '28'
minSdkVersion 14
multiDexEnabled true
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
**SIGNCONFIG**
}
}
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}
dependencies {
compile ('com.adincube.sdk:AdinCube-Unity-3626ebe:2.+#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
}
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
android {
defaultConfig {
multiDexEnabled true
}
}
android {
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}

Mopub Banner ads is not appearing

I am kind of newbie in Android Programming, So I Just want to Display Mopub banner ad in my app. I created the Sample app, also created Ad unit id in Mopub.
I successfully integrated SDK and following their https://developers.mopub.com/docs/android/banner/ instructions on this page.
but I don't know why my app which is Live on G-play Only sending the request but no impression. I also checked on my Phone & its true. No ads are displaying. Here is My Code
Can anyone Help me Please?
mainactivity.java:-
import com.mopub.mobileads.MoPubErrorCode;
import com.mopub.mobileads.MoPubView;
import static com.mopub.mobileads.MoPubView.BannerAdListener;
public class MainActivity extends AppCompatActivity implements BannerAdListener {
private MoPubView mBanner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBanner = (MoPubView) findViewById(R.id.bannerview);
mBanner.setAdUnitId("XXXXXXXXXXXXXXXXXXXXXXXX"); // Enter your Ad Unit ID from www.mopub.com
mBanner.setBannerAdListener(this);
mBanner.loadAd();
}
#Override
protected void onDestroy() {
mBanner.destroy();
super.onDestroy();
}
#Override
public void onBannerLoaded(MoPubView banner) {
Log.d("MoPub Demo", "Banner loaded callback.");
}
#Override
public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {
Log.d("MoPub Demo", "Banner failed callback with: " + errorCode.toString());
}
#Override
public void onBannerClicked(MoPubView banner) {
Log.d("MoPub Demo", "Banner clicked callback.");
}
#Override
public void onBannerExpanded(MoPubView banner) {
Log.d("MoPub Demo", "Banner expanded callback.");
}
#Override
public void onBannerCollapsed(MoPubView banner) {
Log.d("MoPub Demo", "Banner collapsed callback.");
}
}
Activity_main.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mopub.mobileads.MoPubView
android:id="#+id/bannerview"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Build.gradle(module.app):-
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.your.prject.appmopubtest"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('com.mopub:mopub-sdk:4.20.0#aar') {
transitive = true
}
}
Build.gradle(project.appmopubtest):-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
androidmanifest.xml:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.prject.appmopubtest">
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional permissions. Will pass Lat/Lon values when available. Choose either Coarse or Fine -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- All ad formats -->
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Interstitials -->
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Rewarded Video and Rewarded Playables -->
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
</application>
</manifest>

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.

Categories

Resources