Use AIDL Interfaces Through Module / Subprojects in Gradle

I have a project consisting of several gradle modules (plugin com.android.library) referencing each other (tree, not plane). I use AIDL extensively, and therefore it happens that I refer to the AIDL interfaces from one module (modA) in the AIDL interface in another module (modB).

Móda / SRC / Primary / aidl / Móda / foo.aidl:

package modA; 
interface foo {
    void modAcall();
}

MODB / SRC / Basic / aidl / MODB / bar.aidl:

package modB;
import modA.foo;
interface bar {
    foo modBcall();
}

MODB / build.gradle:

dependencies {
    compile project(':modA')
}

I can reference parcelables modA in AIDL files in modB, and I can reference modA interfaces in java code in modB, but not in AIDL in modB. Instead, an error message is couldn't find import for classdisplayed using the helpl tool.

, .aar , . , , , .

helpl , , . , src modB, - modA.

  • aar, ?
  • include1 gradle helpl ( , helpl ), "" ( / java aar/module)?
+6
2

. gradle Android , aidl .aar. .

// In modA build.gradle
android {
    aidlPackageWhiteList "src/main/aidl/foo.aidl"
}

, , , .

: , modA (), modB ( , .

+6

"aidlPackageWhiteList", "aidlPackageWhiteList ", , .

  // in modB build.gradle
  android {
        sourceSets {
            main {
                aidl.srcDirs += '../src/main/aidl'    // locate your modA aidl directory 
            }
        }
    }
0

Source: https://habr.com/ru/post/1650152/


All Articles