Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Support root project build.gradle OR Provide a detailed error of the issue #48

Open
jkasten2 opened this issue Jun 10, 2018 · 6 comments

Comments

@jkasten2
Copy link
Member

jkasten2 commented Jun 10, 2018

Issue

Currently if this plugin is applied to the root build.gradle instead of app/build.gradle the following error is shown.

Could not get unknown property 'android' for root project 'ProjectName' of type org.gradle.api.Project.

Solutions

Solutions below are in order of the best outcome

1. Solution - Apply plugin to all projects

If possible this plugin should apply itself to all Android projects

2. Solution - Provide a detailed error

We should provide a detailed message to move the plugin to their app/build.gradle. We should still cause the build to fail so the app developer knows that the plugin is not working.

@kodeine
Copy link

kodeine commented Jul 30, 2018

@jkasten2 i am getting the following error even though /build.gradle in root does not have anything related to onesignal. But app/build.gradle has it.

app/build.gradle

.....
// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-firebase-analytics/app-build.gradle"
apply from: "../onesignal-cordova-plugin/app-build-extras-onesignal.gradle"
// PLUGIN GRADLE EXTENSIONS END
......
dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    compile "com.android.support:support-v4:27.+"
    compile "com.facebook.android:facebook-android-sdk:4.+"
    compile "com.google.firebase:firebase-core:16.0.0"
    compile "com.android.support:support-v4:26.+"
    compile "com.android.support:appcompat-v7:26.+"
    compile "com.onesignal:OneSignal:3.9.1"
    // SUB-PROJECT DEPENDENCIES END
}

ERROR

ANDROID_HOME=/Users/user/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

FAILURE: Build failed with an exception.

* Where:
Script '/Project/platforms/android/onesignal-cordova-plugin/app-build-extras-onesignal.gradle' line: 1

* What went wrong:
A problem occurred evaluating script.
> Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:79079) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Project/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script '/Project/platforms/android/onesignal-cordova-plugin/app-build-extras-onesignal.gradle' line: 1

* What went wrong:
A problem occurred evaluating script.
> Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:79079) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@jkasten2
Copy link
Member Author

@kodeine I recommend making sure you have the latest Cordova version 8.0.0 and the project is also using Cordova android@7.0.0 or newer.

Please open a new issue on OneSignal-Cordova-SDK/issues if you are still seeing an issue.

@rendy14s
Copy link

rendy14s commented Apr 12, 2020

hi @jkasten2 is there any update about this? because i got the same issues here :)

@jkasten2
Copy link
Member Author

@rendy14s Can you add apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' to your app/build.gradle instead of your root build.gradle per these instructions?
https://github.com/OneSignal/OneSignal-Gradle-Plugin#setup

@rendy14s
Copy link

@jkasten2 can not, i have some error like you.
Could not get unknown property 'android' for root project 'ProjectName' of type org.gradle.api.Project.

@jkasten2
Copy link
Member Author

@rendy14s I am not sure I understand. What blocks you from being able to modify your app/build.gradle? Note that app is the default for Android projects, you could have a different name or multiple if modified this.

Can you provide more detail on your project such as if is using something like Flutter, React Native, or a completely native Android project?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants