psambit9791 / jdsp

A Java Library for Digital Signal Processing
https://jdsp.dev
MIT License
240 stars 45 forks source link

Build error due to org.apache.maven Duplicate #62

Closed tusharrain28 closed 1 year ago

tusharrain28 commented 1 year ago

Hello,

I have experienced the exact same issue as issue #5 but I am not able to solve the issue.

After following the steps, I am getting the following error:

`A problem occurred evaluating project ':app'.

Could not find method com.github.psambit9791:jdsp:2.0.1() for arguments [build_8b7glpftwjyi9ocz81v2e7e82$_run_closure2$_closure9@1fa01953] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Kindly help in resolving the issue. Thanks

psambit9791 commented 1 year ago

@tusharrain28 can you share the gradle file please?

tusharrain28 commented 1 year ago

I just created a new projected and added the lib

Project gradle file :

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
    }
}

plugins {
    id 'com.android.application' version '7.4.2' apply false
    id 'com.android.library' version '7.4.2' apply false
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
        }
        google()
    }
}

Module gradle file:

plugins {
    id 'com.android.application'
}

android {
    namespace 'com.example.fft'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.fft"
        minSdk 33
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    packagingOptions {
        // Exclude these files because they conflict with those imported from the jDSP package
        exclude 'META-INF/*'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildFeatures {
        viewBinding true
    }

}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.4.1'
    implementation 'androidx.navigation:navigation-ui:2.4.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.github.psambit9791:jdsp:2.0.1' {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    }
}
psambit9791 commented 1 year ago

@tusharrain28 Could you try and take a look at this: https://github.com/gradle/gradle/issues/22550#issuecomment-1295018616? Appears to be a similar issue to what you encountered.

karansingla007 commented 1 year ago

any update on this? i am also getting same error

psambit9791 commented 1 year ago

Based on this solution for the same issue with the DefaultDependencyHandler , this is an issue with the syntax used for including JDSP - the exclusions require the unsugared version.

Could you please replace:

implementation 'com.github.psambit9791:jdsp:2.0.1' {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    }

with this:

implementation('com.github.psambit9791:jdsp:2.0.1', {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    })

OR

implementation('com.github.psambit9791:jdsp:2.0.1') {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    }
skaran0007 commented 1 year ago

image @psambit9791 See still i am getting error after using

psambit9791 commented 1 year ago

As mentioned with the error, you will need to add packagingOptions in your build.gradle file

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
}

Although, I don't think this is directly linked to the issue originally reported herein.

psambit9791 commented 1 year ago

@tusharrain28 @skaran0007 @karansingla007 Can you confirm if this fixes the issue encountered?

tusharrain28 commented 1 year ago

@psambit9791 i can confirm the fix is working correctly. Somehow i was not able to post any comment before :)

skaran0007 commented 1 year ago

@tusharrain28 @psambit9791 i am getting the same error.

psambit9791 commented 1 year ago

@skaran0007 Can you elaborate on what the issue is? Maybe provide details on your gradle file.

psambit9791 commented 1 year ago

@skaran0007 I am not sure if this is the gradle file you wanted to share. This has no mention of jdsp in it.

karansingla007 commented 1 year ago

@psambit9791 see this

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-ml-common:22.1.2'
    implementation 'com.google.firebase:firebase-ml-model-interpreter:22.0.4'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    /* Contracts */
    implementation 'androidx.activity:activity-ktx:1.7.0'
    implementation 'androidx.fragment:fragment-ktx:1.5.6'

    /* Bluetooth*/
    implementation 'com.github.LeandroSQ:android-ble-made-easy:1.8.0'

    /* Navigation */
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
    implementation "androidx.navigation:navigation-dynamic-features-fragment:2.5.3"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // graph view
    implementation 'com.jjoe64:graphview:4.2.2'
    implementation 'com.pusher:pusher-java-client:1.8.0'
    implementation 'com.google.code.gson:gson:2.9.0'

    //tf lite
    implementation 'com.google.firebase:firebase-ml-modeldownloader-ktx:24.1.2'
    implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
    implementation 'org.tensorflow:tensorflow-lite-support:0.4.3'

    implementation('com.github.psambit9791:jdsp:2.0.1', {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    })

}

the error i am getting image

psambit9791 commented 1 year ago

@karansingla007 It is difficult to identify issues regarding the build if the full gradle file is not provided. I would suggest sharing the entire content of the gradle file. From the error, it appears to be arising from DEPENDENCIES file not being ignored,

karansingla007 commented 1 year ago

@psambit9791

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'androidx.navigation.safeargs'
    id 'org.jetbrains.kotlin.android'

}
apply plugin: 'com.google.gms.google-services'

android {
    namespace 'com.aavaa'
    compileSdk 33

    aaptOptions {
        noCompress "tflite", "lite"
    }

    defaultConfig {
        applicationId "com.aavaa"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        viewBinding true
    }

    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1,NOTICE.md,LICENSE.md}'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.google.firebase:firebase-ml-common:22.1.2'
    implementation 'com.google.firebase:firebase-ml-model-interpreter:22.0.4'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    /* Contracts */
    implementation 'androidx.activity:activity-ktx:1.7.0'
    implementation 'androidx.fragment:fragment-ktx:1.5.6'

    /* Bluetooth*/
    implementation 'com.github.LeandroSQ:android-ble-made-easy:1.8.0'

    /* Navigation */
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
    implementation "androidx.navigation:navigation-dynamic-features-fragment:2.5.3"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // graph view
    implementation 'com.jjoe64:graphview:4.2.2'
    implementation 'com.pusher:pusher-java-client:1.8.0'
    implementation 'com.google.code.gson:gson:2.9.0'

    //tf lite
    implementation 'com.google.firebase:firebase-ml-modeldownloader-ktx:24.1.2'
    implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly'
    implementation 'org.tensorflow:tensorflow-lite-support:0.4.3'

    implementation('com.github.psambit9791:jdsp:2.0.1', {
        exclude group: 'org.apache.maven.surefire', module: 'common-java'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    })
}
psambit9791 commented 1 year ago

@karansingla007 Under packagingOptions, could you please try adding DEPENDENCIES as shown below.

packagingOptions {
    resources {
        excludes += '/META-INF/{DEPENDENCIES,AL2.0,LGPL2.1,NOTICE.md,LICENSE.md}'
    }
}

For details, please refer to this response

karansingla007 commented 1 year ago

@psambit9791 no luck Error is same

image
psambit9791 commented 1 year ago

@karansingla007 This isn't the same error. As you see, it mentions LICENSE-notice.md and not DEPENDENCIES. So, you have to exclude the LICENSE-notice.md in the packagingOptions as well. You need to keep excluding all the files which show up as conflicts under the META-INF directory.

psambit9791 commented 1 year ago

Hi @karansingla007 Can you confirm that the build issue has been resolved? Any further problems not pertaining to the build issue requires a new issue to be raised.

karansingla007 commented 1 year ago

yeah, it resolved And very very thanks for that.

psambit9791 commented 1 year ago

@karansingla007 Can you please create a new ticket for the Butterworth issue you are encountering?

humaneBicycle commented 1 year ago

implementation('com.github.psambit9791:jdsp:2.0.1', { exclude group: 'org.apache.maven.surefire', module: 'common-java' exclude group: 'org.apache.maven.surefire', module: 'surefire-api' })

bro this actually worked!! really the brackets messed up my time. Thanks for the excellent library btw :)

BladLust commented 2 weeks ago

Help! I'm having new issues regarding this fix. First of all thanks a lot for this awesome library! But after applying the above-mentioned fixes (including exclude surefire, adding packagingOptions), the app crashes when I try to plot. Logcat says it's missing the font resources. I remember seeing some kind of font library when I was debugging this and I suspect that excluding DEPENDENCIES removed the font resource files. Is there a way to fix that as well? Sorry if this is a stupid question, I'm fairly new to Android developing. Screenshot 2024-06-20 at 5 01 04 PM