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

Error: Command gradlew.bat failed with exit code 1 #28

Closed mablejohn closed 6 years ago

mablejohn commented 6 years ago

Hello,

I would like to create a Cross platform project using TNS.

I tried your tutorial and I ran few commands

And ended up with the following stack-trace.

Would you please tell me what I am doing wrong?

Thanks a lot. Mable John

The stack trace:

**λ tns run android**                                                                                                                               
Searching for devices...                                                                                                                        
Skipping prepare.                                                                                                                               
Building project...                                                                                                                             
Gradle build...                                                                                                                                 
         + applying user-defined configuration from E:\tns_repos\HelloWorld\app\App_Resources\Android\app.gradle                                
         + adding nativescript runtime package dependency: nativescript-optimized                                                               
         + adding aar plugin dependency: E:\tns_repos\HelloWorld\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar    
false                                                                                                                                           

**FAILURE: Build failed with an exception.**                                                                                                        

* Where:                                                                                                                                        
Build file 'E:\tns_repos\HelloWorld\platforms\android\build-tools\android-static-binding-generator\build.gradle' line: 63                       

* What went wrong:                                                                                                                              
Execution failed for task ':asbg:generateInterfaceNamesList'.                                                                                   
> Could not get unknown property 'jarFiles' for project ':asbg' 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 6s                                                                                                                              
Unable to apply changes on device: emulator-5554. Error is: Command gradlew.bat failed with exit code 1.                                      
Darahat commented 6 years ago

i also have facing same problem.Please anyone solve this issue.

xlmnxp commented 6 years ago

same problem in #19

to fix problem do that: step 1: replace file settings.gradle in app/App_Resources with:

import groovy.json.JsonSlurper

task replaceSettings {
    description "Replaces configuration settings."
    def jsonSlurper = new JsonSlurper()
    def pathToSettingsJson

    if (project.hasProperty("appResourcesPath")) {
        pathToSettingsJson = "$project.appResourcesPath/Android/settings.json";
    } else {
        pathToSettingsJson = "$rootDir/../../app/App_Resources/Android/settings.json";
    }

    def settingsJsonFile = file(pathToSettingsJson);
    def settingsResolvedPath = settingsJsonFile.getAbsolutePath();

    if(settingsJsonFile.exists())
    {
        println "\t Applying settings from $settingsResolvedPath"
        String settingsGradleTemplate = """android {
            defaultConfig {
                applicationId = "__appId__"

                if (__minSdkVersion__) {
                    minSdkVersion = __minSdkVersion__
                }

                if (__targetSdkVersion__) {
                    targetSdkVersion = __targetSdkVersion__
                }
                manifestPlaceholders = [onesignal_app_id: "__onesignal_app_id__", onesignal_google_project_number: "REMOTE"]
            }
        }"""

        def settingsJsonContent = settingsJsonFile.getText("UTF-8");
        def settingsMap = jsonSlurper.parseText(settingsJsonContent);

        for ( setting in settingsMap ) {
            def placeholder = "__${setting.key}__";
            def settingValue = setting.value;

            if (settingValue == null) {
                settingValue = false
            }

            settingsGradleTemplate = settingsGradleTemplate.replaceAll( placeholder, settingValue as String);
        }

        new File( "$rootDir/temp_setting.gradle" ).write( settingsGradleTemplate, 'UTF-8');
        apply from: "$rootDir/temp_setting.gradle";
    }
}

don't forget replace __onesignal_app_id__ with your OneSignal app id

step 2:

tns platform clean android

step 3:

tns run android
mablejohn commented 6 years ago

No such file (settings.gradle) in app/App_Resources

I updated NativeScript CLI Tooling and Android runtimes then the problem went away.

Environment information

√ Your ANDROID_HOME environment variable is set and points to correct directory.                                        
√ Your adb from the Android SDK is correctly installed.                                                                 
√ The Android SDK is installed.                                                                                         
√ A compatible Android SDK for compilation is found.                                                                    
√ Javac is installed and is configured properly.                                                                        
√ The Java Development Kit (JDK) is installed and is configured properly.                                               
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can
 use the NativeScript cloud infrastructure.                                                                             
No issues were detected.                                                                                                
√ Getting NativeScript components versions information...                                                               
√ Component nativescript has 4.0.0 version and is up to date.                                                           
√ Component tns-core-modules has 4.0.0 version and is up to date.                                                       
√ Component tns-android has 4.0.1 version and is up to date.                                                            
× Component tns-ios is not installed.