OneSignal audience Not Subscribed even if they are active users - android

I'm trying to implement push notifications feature within my react native Expo app. I'm trying to do so by integrating Onesignal with Firebase. I followed this documentation:
"https://documentation.onesignal.com/docs/react-native-expo-sdk-setup"
I managed to prebuild the app and run it on the android emulator and the user is added in the onesignal dashboard but with subscription status not subscribed OneSignal Audience Dashboard
Note : the notifications settings on the emulator for my app are ON
according to Onesignal documentation the users should be subscribed automatically once they use the app for the first time, here are some logs if needed:
› npx expo run:android
› Building app...
Starting a Gradle Daemon (subsequent builds will be faster)
Configuration on demand is an incubating feature.
Configure project :expo-application
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the gradle.properties file or use the new publishing DSL.
Configure project :expo-constants
(same warning)
Configure project :expo-file-system
(same warning)
Configure project :expo-font
(same warning)
Configure project :expo-keep-awake
(same warning)
Configure project :expo-linear-gradient
(same warning)
Configure project :expo-modules-core
(same warning)
Configure project :expo-splash-screen
(same warning)
Configure project :expo
Using expo modules
expo-application (5.0.1)
expo-constants (14.0.2)
expo-file-system (15.1.1)
expo-font (11.0.1)
expo-keep-awake (11.0.1)
expo-linear-gradient (12.0.1)
expo-modules-core (1.1.1)
expo-splash-screen (0.17.5)
(same warning)
Configure project :react-native-reanimated
AAR for react-native-reanimated has been found
C:\Users..\source\repos...\node_modules\react-native-reanimated\android\react-native-reanimated-70-jsc.aar
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: "https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl"
The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':react-native-screens'
Task :expo-constants:createDebugExpoConfig
Execution optimizations have been disabled for task ':expo-constants:createDebugExpoConfig' to ensure correctness due to the following reasons:
Gradle detected a problem with the following location: 'C:\Users...\source\repos...\android'. Reason: Task ':expo-constants:createDebugExpoConfig' uses this output of task ':app:checkDebugAarMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer
to "docs.gradle.org/7.3.3/userguide/validation_problems.html#implicit_dependency" for more details about this problem.
Task :expo-modules-core:downloadBoost UP-TO-DATE
Download "boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz"
Task :expo-modules-core:downloadDoubleConversion UP-TO-DATE
Download "github.com/google/double-conversion/archive/v1.1.6.tar.gz"
Task :expo-modules-core:downloadFolly UP-TO-DATE
Download "github.com/facebook/folly/archive/v2021.07.22.00.tar.gz"
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See "docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings"
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD SUCCESSFUL in 2m 51s
I added the local.properties manually with this inside: sdk.dir=C:\Users\...\AppData\Local\Android\sdk
I changed the gradel version in gradel-wrapper.properties to the version 7.3.3distributionUrl="https://services.gradle.org/distributions/gradle-7.3.3-all.zip"
In build.gradel inside android section I changed compileSdkVersion and targetSdkVersion to 32

Related

How to upgrade React Native project after upgrading Android Studio

I have upgraded React Native from version 0.68.1 to version 0.70.2, and react from 17.0.2 to 18.1.0. That has worked fine, but I have also upgraded Android Studio to version 2021.3.1. I updated configuration files with the React Native CLI, npx react-native upgrade. Then I attempted to upgrade the android directory according to the React Native Upgrade Helper and manual edits that are necessary to sign an android app. That failed, so I have tried a backup copy but now that fails too despite the fact that the android directory is unchanged from when the app was building correctly. I used Git to revert to a known working copy.
I don't see any procedures to upgrade the Android files after upgrading Android Studio from React Native. Is there any available guidance for the version of Android Studio I use? How can I upgrade the Android project to get it to build with the new version of Android Studio? I'm guessing that Gradle versioning has a lot to do with the errors but I haven't found any explanation or advice to upgrade the project after upgrading Android Studio.
The error I get from PowerShell after running .\gradlew bundleRelease is
Task :app:signReleaseBundle FAILED
w: Detected multiple Kotlin daemon sessions at build\kotlin\sessions
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
> java.lang.OutOfMemoryError (no error message)
When I open the Android folder in Android Studio I notice errors in MainApplication.java and AsyncStoragePackage.java: Cannot resolve symbol 'BuildConfig'. Invalidating the cache, clean, and rebuild have not changed the results.
The answer was found earlier on GitHub. In my instance, there are other messages and the relevant error message is Detected multiple Kotlin daemon sessions at build\kotlin\sessions. Simply adding the code to android/build.gradle as follows fixed the issue for me. I expect the version will need to be updated periodically and I'm now sure how to get the version info as my Kotlin REPL will not start.
belbuildscript {
ext {
// ...
kotlin_version = '1.6.10' // <- add this line
}
dependencies {
// ...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <- add this line
// ...
}
}
I'm guessing that this sort of problem can be avoided by uninstalling Android Studio before installing a more recent version, and other software may need the same treatment.

How can my Gradle plugin define a task depending on a task of AGP 7.0.0?

I have written a Gradle plugin based on Android Gradle Plugin: for each variant, the plugin defines a task generatevariantStuff that generates an asset and I need that the mergevariantAssets (defined by AGP) takes my asset as an input, so the mergevariantAssets task must depend on my generatevariantStuff task.
My plugin works properly with AGP 4.2.2.
AGP 7.0.0 deprecates com.android.build.gradle.api.ApplicationVariant and replaces it by com.android.build.api.variant.ApplicationVariant, so that I have to replace also com.android.build.gradle.AppExtension by com.android.build.api.variant.ApplicationAndroidComponentsExtension and the loop on the variants.
Now, when Android Studio builds the model, it fails with the following error:
A problem occurred configuring project ':app'.
> Task with name 'mergeDebugAssets' not found in project ':app'.
But in Gradle view of Android Studio a can see the mergeDebugAssets task.
It seems that during the method AppExtension.getApplicationVariants().all() (AGP 4.2.2), AGP has already defined its tasks, while, during the method ApplicationAndroidComponentsExtension.onVariants() (AGP 7.0.0), AGP has not yet defined its tasks.
You can see sample code at https://gist.github.com/dscoppelletti/d4ca0e1a19ed4ba4aaea99cf48ae930a
Any help is appreciated.
I have similar issues with it. I have an aggregated task that collects artifacts from each variant and copies them to a given path, but assemble tasks for variants are not available during ApplicationAndroidComponentsExtension.onVariants()

Android gradle plugin v3.3.0 -> can't find R$raw when using proguard

Just updated to Android gradle plugin version 3.3.0
We have the following setup (not sure which are important):
Application project (app) with 3 library modules (data, domain, utils)
Databinding enabled (databinding.enabled true)
Proguard enabled(proguardFiles 'proguard-rules.pro')
When I build the app using:
./gradlew assembleDevRelease
I get the following error:
can't find referenced class my.package.data.R$raw
When I build the app using:
./gradlew :app:assembleDevRelease
The app builds fine, generates an obfuscated *.apk which I can install
Question:
What's the difference between assembleRelease and :app:assembleRelease
- Why does switching to android gradle plugin 3.3.0 affect which task I have to call to build my apk? We use assembleRelease everywhere in our CI pipelines to build our apks.
What changed in android gradle plugin 3.3.0 that caused the task assembleRelease to break? We use assembleRelease everywhere in our CI pipelines to build our apks.
Any suggestions how we can make 'assembleRelease' working again? (update Proguard config?, enabling R8?)
What's the difference between assembleRelease and :app:assembleRelease
The former runs the assembleRelease task on all modules relative to current level. The latter runs it on the app module only (and its dependencies).
Why does switching to android gradle plugin 3.3.0 affect which task I have to call to build my apk? We use assembleRelease everywhere in our CI pipelines to build our apks.
The question does not have enough info to say for sure, but there are a number of changes listed in the release notes. For example, this issue might be related to:
Faster R class generation for library projects: Previously, the Android Gradle plugin would generate an R.java file for each of your project's dependencies and then compile those R classes alongside your app's other classes. The plugin now generates a JAR containing your app's compiled R class directly, without first building intermediate R.java classes. This optimization may significantly improve build performance for projects that include many library subprojects and dependencies, and improve the indexing speed in Android Studio.

Building cordova-plugin-xapkreader with cordova-android 6.4.0

I've inherited a cordova project that uses cordova-plugin-xapkreader, which appears to be the standard plugin for accessing expansion (aka OBB) files. I'm encountering an issue with it that I would expect to affect other cordova plugins. I get the following errors when running cordova build android:
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'implementation' instead.
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'debugCompile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'debugImplementation' instead.
Configuration 'releaseCompile' in project ':com.flyingsoftgames.xapkreader:downloader_library' is deprecated. Use 'releaseImplementation' instead.
Configuration 'compile' in project ':com.flyingsoftgames.xapkreader:library' is deprecated. Use 'implementation' instead.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':debugCompileClasspath'.
> Could not resolve project :com.flyingsoftgames.xapkreader:library.
Required by:
project : > project :com.flyingsoftgames.xapkreader:downloader_library
> Project :com.flyingsoftgames.xapkreader:downloader_library declares a dependency from configuration 'debugCompile' to configuration 'debug' which is not declared in the descriptor for project :com.flyingsoftgames.xapkreader:library.
This has been reported as a bug on the plugin's forum by someone else, but the workaround doesn't reliable work:
https://github.com/agamemnus/cordova-plugin-xapkreader/issues/116
The issue appears to be that gradle expects you to now use implementation rather than compile, debugCompile etc. The gradle file for the plugin is generated by cordova, based on a template inside cordova-android. The suggested workaround is to modify the template (or the generated gradle files) in a script run from a cordova hook. Unfortunately for some reason, the hooks don't appear to work reliably - sometimes they do, sometimes they don't. This feels like it may be due to a race condition caused by the hooks running asynchronously with the rest of the build process - so sometimes the gradle build has started before the gradle files can be modified.
Does any have any ideas how to properly fix this? Does anyone know why this isn't a more wide-spread issue that the cordova-android project hasn't fixed by modifying their template? Is this something I can fix by downgrading some part of the build process?
I'm pretty new to Cordova, so it's all quite baffling and any help is much appreciated!
Unfortunately for some reason, the hooks don't appear to work reliably
- sometimes they do, sometimes they don't. This feels like it may be due to a race condition caused by the hooks running asynchronously
with the rest of the build process - so sometimes the gradle build has
started before the gradle files can be modified.
I think this can be fixed by making the hook return a promise, this way you can ensure the rest of the build won't run in parallel. I posted the code I'm using on the github issue.
The revelant code is the following:
- create a promise at the beginning of the hook:
const deferral = context.requireCordovaModule('q').defer();
- return the promise at the end of the hook:
return deferral.promise;
- resolve the promise once the work is finished (the file is written):
deferral.resolve();

"Could not initialize class" error running lint target from gradle

I'm working on an Android project with two projects inside it. When trying to run a build with gradlew (./gradlew build), I see the following error:
Execution failed for task ':example:lint'.
Could not initialize class
com.android.build.gradle.tasks.Lint$LintGradleIssueRegistry
With stacktrace enabled, this is listed as a java.lang.NoClassDefFoundError.
Oddly, the first time I ran this (which downloaded dependencies), the build failed with a different error:
Execution failed for task ':example:lint'.
lombok/ast/Node
The gradle wrapper that Android SDK created for the project is using Gradle 2.8.
Could this be a configuration issue with the project or my dev machine? I'm trying to avoid using the Android SDK lint tool as this complains about the projects using Gradle (and I hear it may miss some parts of these projects).
Turned out this was a configuration issue in our build.gradle. The following line had been added for testing and never removed:
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
As such, the classes needed for linting were missing.
The following discussion pointed us in the right direction, in case it's useful to anyone else:
https://github.com/evant/gradle-retrolambda/issues/96

Categories

Resources