12

I'm developing an plugin to cordova which uses an brazilian payment api called pagseguro. But that's not the point.

When I add my cordova plugin to my project and run "cordova run android", I receive this error and I don't know how to proceed:

Execution failed for task ':app:compileDebugJavaWithJavac'.

Unable to find source java class: '/home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/src/main/java/main/java/com/pagseguroCordova/PagseguroCordova.java' because it does not belong to any of the source dirs: '[/home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/src/main/java, /home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/src/debug/java, /home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/build/generated/source/r/debug, /home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/build/generated/source/buildConfig/debug, /home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/build/generated/source/aidl/debug, /home/marcelo/Documents/Delicia-e-Foco/app/platforms/android/app/build/generated/source/rs/debug]'

Already tried to modify my plugin.xml. this is the plugin.xml right now:

<?xml version="1.0" encoding="UTF-8"?>
    <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-pagseguro"
version="1.0.0">

<js-module src="./www/plugin.js" name="plugin">
    emphasized text<clobbers target="PagseguroCordova" />
</js-module>

<!-- android -->
<platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="pagseguroCordova" >
            <param name="android-package" value="com.example.pagseguroCordova"/>
        </feature>
    </config-file>

    <framework src="build.gradle" custom="true" type="gradleReference" />
    <framework src='br.uol.pagseguro.client:btserial:1.1.0' />
    <framework src='br.uol.pagseguro.client:plugpag:1.1.0' />
    <source-file src="src/android/PagseguroCordova.java" target-dir="src/main/java/com/pagseguroCordova/" />
</platform>

I'm using gradle to import dependecies, this is my build.gradle file:

repositories {
    jcenter()
        maven {
            url 'https://github.com/pagseguromaster/plugpag/raw/master/android'
    }
}

dependencies {
    compile 'br.uol.pagseguro.client:btserial:1.1.0'
    compile 'br.uol.pagseguro.client:plugpag:1.1.0'
}

Someone knows what is causing this error? Thanks for the attention.

user3119509
  • 175
  • 1
  • 2
  • 7

4 Answers4

7

Deleting the .idea and .gradle folders worked for me.

Next time you launch open the project folder in Android Studio it should recreate them.

However it then gives me the Android Studio: "Please select Android SDK" dialog.

Fix for me is: File -> Project Structure -> (modules)App -> BuildToolsVersion -> ... and then (bizarrely) click to open the pulldown and click on the exact same item that was already selected.

And then rebuild.

Sort it out, Google!

(Android Studio 3.1.2)

P i
  • 29,020
  • 36
  • 159
  • 267
4

I am not using any special IDE (yes I live under a rock)

cordova clean

works for me

Arindam
  • 537
  • 1
  • 5
  • 8
  • This command saved me from a lot of headaches. The only alternative was to remove and add the platform again. Thanks! – Sterex Oct 09 '19 at 08:12
3

A 'Clean Project' from the Android Studio 'Build' dropdown fixed this for me.

Jochem
  • 2,995
  • 16
  • 18
  • The problem for me seems to be that a directory is symlinked into the project which is also an NFS share and Android Studio does not like that. I don't know if the symlink or the NFS causes the problem, but I have to do the CLean Project every time I modify something from the symlinked directory. – soger Jul 03 '19 at 15:51
0

In case you having this issue in Jenkins, go to your project

Workspace -> Wipe Out Current Workspace (click on it)

Daniel
  • 36,833
  • 10
  • 119
  • 200