roblav96 / nativescript-onesignal

A Nativescript plugin that wraps the iOS and Android OneSignal Push Notifications SDK.
https://documentation.onesignal.com/docs/getting-started
Other
24 stars 42 forks source link

v1.0.8 - Incompatible with TNS 3, 4 and 4.1 #38

Open kvindascr opened 6 years ago

kvindascr commented 6 years ago

The hook provided with v1.0.8 is causing issues with TNS 3, 4 and 4.1

The specific problem is that it turns the platforms/android/app/build.gradle unusable.

In specific this text portion.

def pluginDependencies = nativescriptDependencies.collect {
        "$rootDir/${it.directory}
          maven { url "https://plugins.gradle.org/m2/" }
/$PLATFORMS_ANDROID"
    }

This makes the whole compilation fail. I have also reproduced on a new clean project.

The error indicated when compiling is:

 build file '/my-project/platforms/android/app/build.gradle': 219: expecting anything but ''\n''; got it anyway @ line 219, column 34.
             "$rootDir/${it.directory}
                                      ^
  1 error

I have tried to modify the build.gradle in several ways to make this version work, but is just not working.

From removing the maven repo altogether, to put it after the repositories and inside of it.

Seems to me that the right way is to put it inside the repositories, but when I do that I get:

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
roblav96 commented 6 years ago

Wait so is v1.0.8 not working at all?

kvindascr commented 6 years ago

Hello @roblav96 I was not able to make it work with my project in any way.

Not with tns3, or tns4 or tns41.

Not even trying to hack the build.gradle.

Also as comment I review the hook and the issue is that the regex you are using is no longer matching the build.gradle, at least from the perspective you are expecting.

But even when I was able to get the project building, I use to get a multidex error I got above. On android studio it stated that a class was repeated.

Let me know if you require any other info.

endymion00 commented 6 years ago

I also tried to hack the gradle file I got the same results. I'm not expert in subject but my conclusion was that due to google packages changes now there is a problem when trying to adapt the gradle file the same way as onesignal states on their website. I tried to set that packages by hand with no luck. Then I discovered that onesignal uses a plugin that solves google packages compatibility and it is included in the configuration section. I tried to use this plugin but due to nativescript does not use a newer version of gradle it didn't succeed.

Onesignal sdk setup: https://documentation.onesignal.com/docs/android-sdk-setup (line "apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'" was the one it didn't work) Plugin: https://github.com/OneSignal/OneSignal-Gradle-Plugin

thematan commented 6 years ago

I also have problems with version 1.0.8. it corrupts my build.gradle file with maven { url : ... } which makes it unreadable

webmeemba commented 6 years ago

I also have problems with version 1.0.8. it corrupts my build.gradle file with maven

ianrothmann commented 6 years ago

I have the same problem with 1.0.8.

yclau commented 6 years ago

I have the same problem with 1.0.8.

jkasten2 commented 6 years ago

I believe this issue was related to the post hooks added in 1.0.8. I remove them in this fork which I believe should fix the issue. https://github.com/OneSignal/nativescript-onesignal

Can you try this fork on a new native script 4.1 project?

amizz commented 6 years ago

I'm getting this error

Could not find method maven() for arguments [build_907m3ahivxu5v3cw8nx6zv3o9$_run_closure1$_closure3@76d35244] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.
OPADA-Eng commented 6 years ago

I'm getting the same error Could not find method maven() for arguments [build_f125p5dtyyowi8ppag9f0hjyx$_run_closure1$_closure3@39bdae10] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

amizz commented 6 years ago

Just a quick fix. Remove any hooks from this library. Then try to rebuild.

MopheusDG commented 6 years ago

Same here. It seems the problem is on the first line of repositories under the app\build.grandle:

repositories { // used for local *.AAR files def pluginDependencies = nativescriptDependencies.collect { "$rootDir/${it.directory} maven { url "https://plugins.gradle.org/m2/" } /$PLATFORMS_ANDROID" }

and also in the \build.gradle:

repositories { google() jcenter() } maven { url "https://plugins.gradle.org/m2/" }

Do you think we get a fix for this anytime soon ? Thanks.

randy-johnson commented 5 years ago

Any updates on this? I tried updating to 1.8 and getting the error referenced above even when using the fork mentioned above.

TLmaK0 commented 5 years ago

install plugin nativescript-onesignal@1.0.7, remove /hooks/* and remove/add platform android as workaround

japasanto commented 5 years ago

Does anyone have the solution for this? i´m using nativescript-sidekick 1.16.2-v.2019.3.13.12 (latest) and NativeScript CLI version: 5.2.3 and i just can´t pass this:

Build file '/mypath/platforms/android/build.gradle' line: 9
* What went wrong:
A problem occurred evaluating root project 'brleads'.
> Could not find method maven() for arguments [build_6oj9snjji1nx2yep6nr5rl96k$_run_closure1$_closure3@158d3909] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

I´m completly stuck!

boomalek commented 5 years ago

Does anyone have the solution for this? i´m using nativescript-sidekick 1.16.2-v.2019.3.13.12 (latest) and NativeScript CLI version: 5.2.3 and i just can´t pass this:

Build file '/mypath/platforms/android/build.gradle' line: 9
* What went wrong:
A problem occurred evaluating root project 'brleads'.
> Could not find method maven() for arguments [build_6oj9snjji1nx2yep6nr5rl96k$_run_closure1$_closure3@158d3909] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

I´m completly stuck!

... me too

arnaldopxm commented 5 years ago

I believe this issue was related to the post hooks added in 1.0.8. I remove them in this fork which I believe should fix the issue. https://github.com/OneSignal/nativescript-onesignal

Can you try this fork on a new native script 4.1 project?

@roblav96 I've seen that indeed @jkasten2 last commit on his fork fixes the error. But this is not published over npm. Could you please publish it.

CapellaBlue commented 5 years ago

Still experiencing issues here. I can create a new issue to make it open, as it's not resolved. tns --version => 5.3.1 Here's what I've done so far to get past most of the issues I see here and in other issues : Install the plugin. First, move maven into repositories within platforms/Android/build.gradle:

repositories {
        google()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }

Then, go to platforms/Android/app/build.gradle, and remove the maven code that's added inside a string. As mentioned above...the regex isn't working.

repositories {
    // used for local *.AAR files
    def pluginDependencies = nativescriptDependencies.collect {
        "$rootDir/${it.directory}/$PLATFORMS_ANDROID" #maven is placed here, but you should remove it
    }

THEN, within the same file, under the defaultConfig section, you have to add the manifestPlaceholders:

manifestPlaceholders = [
          onesignal_app_id: 'YOUR ONESIGNAL APP ID HERE',
          onesignal_google_project_number: 'REMOTE' #I also tried creating a firebase app and putting the project number here. It's not moved me past the last issue listed in the post.
        ]

and at the end of this file place the below code. It will already be there if the hook code has run, but you'll have to format it as tabbing is off.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.0'
            }
        }
    }
}

I also then completely remove the hooks added by this plugin to avoid any other issues. Of course, you could delete this first and then go insert the needed information somewhere. Its work either way.

I'm now stuck with "An Uncaught exception occurred on the ...thread...Default FirebaseApp is not initialized in this process...make sure to call FirebaseApp.initializeApp(Contect) first..."

On the onesignal-android-sdk repo, they had a similar problem, but I was not able to follow their solution successfully. It's here. I'm also going to put in an issue asking help from them, as the company references this plugin in their documentation, and it's clearly not working. Maybe they have ideas?