【问题标题】:Android experimental grade plugin won't see my library moduleAndroid 实验级插件不会看到我的库模块
【发布时间】:2015-10-04 10:38:11
【问题描述】:

我正在将 Android 库 (.aar) 编译为包含一些本机代码并需要一些库的模块。这是build.gradle

apply plugin: 'com.android.model.library'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.1"

        defaultConfig.with {
            //
            //  NOTE: change the application ID to match the play console linked application.
            //
            applicationId = "org.anima.mrubybridge"
            minSdkVersion.apiLevel    = 18
            targetSdkVersion.apiLevel = 18
        }
    }

    android.ndk {
        moduleName = "mrubybridge"
        CFlags += "-I/home/dragos/Downloads/mruby-1.1.0/include"
        CFlags += "-I/home/dragos/Downloads/mruby-1.1.0/include"
        ldLibs += ["mruby"]
    }
    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles  += file('proguard-rules.txt')
        }
    }
    android.productFlavors {
        create ("arm7") {
            ndk.abiFilters += "armeabi-v7a"
            ndk.ldFlags += "-L/home/dragos/Downloads/mruby-1.1.0/build/armeabi-v7a/lib"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

这会编译所有内容(我检查了 .class 和 .so 文件),但 .aar 档案几乎是空的,没有类或动态库。 (约 2.3KB)

在第二个模块中,我将其添加为依赖项:

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.1"

        defaultConfig.with {
            //
            //  NOTE: change the application ID to match the play console linked application.
            //
            applicationId = "com.example.dragos.mrubytest"
            minSdkVersion.apiLevel    = 18
            targetSdkVersion.apiLevel = 18
        }
    }

    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles  += file('proguard-rules.txt')
        }
    }
}

dependencies {
    compile project(':mrubybridge')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
}

但是当我尝试从其他模块添加 Java 类时,我得到:Error:(12, 29) error: package org.anima.mrubybridge does not exist,很可能是因为它们不在 .aar 中。

我已将该模块添加为依赖项 (compile project(':mrubybridge')),但它并没有真正的帮助。

【问题讨论】:

    标签: android android-ndk android-gradle-plugin build.gradle


    【解决方案1】:

    我遇到了同样的问题。这个答案为我解决了:

    @Radix

    “将 .aar 文件放在 app libs 目录中(如果需要,创建它),然后,在你的 app build.gradle 中添加以下代码”:

    dependencies {
       compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
     }
    repositories{
          flatDir{
                  dirs 'libs'
           }
     }
    

    Adding local .aar files to Gradle build using "flatDirs" is not working

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多