3

First of all, this may be a duplicate, but I've searched tons of hours trying get this error fixed, and none of the found pages about this topic helped me fix my error. Here are some places I went:

Test.java (Implements Parcelable):

package com.app.pack.classes;

public class Test implements Parcelable {

private int test = 33;

protected Test(Parcel in) {
    test = in.readInt();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(test);
}

@Override
public int describeContents() {
    return 0;
}

public static final Creator<Test> CREATOR = new Creator<Test>() {
    @Override
    public Test createFromParcel(Parcel in) {
        return new Test(in);
    }

    @Override
    public Test[] newArray(int size) {
        return new Test[size];
    }
};
}

Test.aidl (Declares the class I want to send):

package com.app.pack.aidl;
parcelable Test;

TestService.aidl (provides the method that returns a Test object):

package com.app.pack.aidl;
import com.app.pack.aidl.Test;

interface TestService{
Test getAll(in int[] listOfInts);
}

When I rebuild the project in the messages gradle build the outputted error says:

C:\Users...\TestService.java

  • "error: cannot find symbol class Test"

Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

When I check the Gradle Console I found that the error is related to this:

"aidl.exe E 02-28 12:08:49 8288 4608 aidl.cpp:580] refusing to generate code from aidl file defining parcelable"

I've tried to put the Test.java within the same package as Test.aidl and TestService.aidl, but it didn't fix it. Also tried recreating both Test.java and Test.aidl, didn't work either. Also tried to see where the android.mk is on my project, but didn't find it, it either doesn't exist or it is on a path that I don't know. (can't find jni folder either).

Can someone please help me find an answer to why the aidl isn't working/is failing when I try to pass an object of my own? When I try to pass a primitive data type it works perfectly (example: if I try to pass an int instead of a Test, it works).

Mostafa Arian Nejad
  • 1,278
  • 1
  • 19
  • 32
José Soares
  • 31
  • 1
  • 5

1 Answers1

1

There is a mis-match between the package name for your Test class, com.app.pack.aidl in Test.aidl vs com.app.pack.classes in the Java code; they need to match.

As far as I can tell from my own projects, the refusing to generate code error is OK to ignore; there's simply no code to generate from a file that doesn't define an interface, but the tooling blindly runs aidl.exe for all *.aidl files.

Karsten
  • 310
  • 1
  • 6