NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
101 stars 50 forks source link

java.lang.NoSuchMethodError: No direct method <init> #137

Closed jgerryl closed 6 years ago

jgerryl commented 6 years ago

Hi, i have an issue in android when i want to upload file there is an exception

An uncaught Exception occured on "pool-8-thread-1" thread. java.lang.NoSuchMethodError: No direct method (Landroid/content/Context;Ljava/lang/String;)V in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes(declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/org.nativescript.xxx-1/base.apk) at net.gotev.uploadservice.UploadTask.createNotification(UploadTask.java:453) at net.gotevuploadservice.UploadTask.run(UploadTask.java:145) at java.util.concurrent.ThreadPoolExecuter.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

i already search for similar issues like this one but still has no successful attempt. Many said we should change in build.gradle


    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 26
        //ndk {
        //  abiFilters "armeabi-v7a", "x86"
        //}
    }

dependencies {

    compile "com.android.support:support-v4:26.0.2"
    compile "com.android.support:appcompat-v7:26.0.2"
    debugCompile "com.android.support:design:26.0.2" 
}

my CLI Version is 3.4.0. My package.json

{
    "description": "NativeScript Application",
    "license": "SEE LICENSE IN <your-license-filename>",
    "readme": "NativeScript Application",
    "repository": "<fill-your-repository-here>",
    "nativescript": {
        "id": "org.nativescript.xxx",
        "tns-android": {
            "version": "3.4.2"
        }
    },
    "dependencies": {
        "@angular/animations": "~5.2.0",
        "@angular/common": "~5.2.0",
        "@angular/compiler": "~5.2.0",
        "@angular/core": "~5.2.0",
        "@angular/forms": "~5.2.0",
        "@angular/http": "~5.2.0",
        "@angular/platform-browser": "~5.2.0",
        "@angular/platform-browser-dynamic": "~5.2.0",
        "@angular/router": "~5.2.0",
        "email-validator": "^1.1.1",
        "nativescript-angular": "~5.2.0",
        "nativescript-background-http": "^3.2.5",
        "nativescript-file-picker": "0.0.2",
        "nativescript-social-login": "^4.0.0",
        "nativescript-social-share": "^1.5.0",
        "nativescript-theme-core": "~1.0.4",
        "nativescript-ui-dataform": "^3.6.0",
        "nativescript-ui-listview": "^3.5.1",
        "nativescript-ui-sidedrawer": "^3.5.1",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~5.5.2",
        "tns-core-modules": "~3.4.0",
        "tns-platform-declarations": "^4.0.0",
        "zone.js": "~0.8.2"
    },
    "devDependencies": {
        "babel-traverse": "6.4.5",
        "babel-types": "6.4.5",
        "babylon": "6.4.5",
        "lazy": "1.0.11",
        "nativescript-dev-typescript": "~0.6.0",
        "typescript": "~2.6.2"
    }
}

Any idea why and how to solve it?

Thanks

jgerryl commented 6 years ago

Hi all,

Already test this. After i remove "nativescript-social-login" it works prefectly. I close this issue

Thanks

gogoout commented 5 years ago

For anyone experience the same error with nativescript-social-login. I was able to use this plugin together with that. Just change the app.gradle to below

project.ext {
    googlePlayServicesVersion = "15.0.0"
    supportVersion = "27.0.2"
}

// MUST INCLUDE THIS PART
dependencies {
    configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion "27.0.2"
                    }
                }
            }
        }
}

android {
  compileSdkVersion 26
  buildToolsVersion "26.0.2"
  defaultConfig {
    generatedDensities = []
    applicationId = "YOURAPPID"
    minSdkVersion 21
    targetSdkVersion 26
    ndk {
      abiFilters "arm64-v8a", "armeabi-v7a", "x86"
    }
  }
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }
}

I believe it's the android support version somehow cause the problem.