相关疑难解决方法(0)

使用多个AAR/JAR创建AAR

我已经看到各种开发者发布的问题(Android Studio将两个.aar合并为一个和其他),但我没有看到一个明确的响应,使我能够创建一个包含一个或多个AAR或JAR的AAR(我可以使用JAR因为我不需要共享任何资源;只有类).这是我的库项目的app.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 21
    }

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

dependencies {
    compile 'com.google.code.gson:gson:2.1'
    compile ('libs/eventbus.jar')
    compile project(':core-release')
    compile project(':midware-release')
}
Run Code Online (Sandbox Code Playgroud)

同样,这个应用程序是一个库项目,需要两个其他库项目('核心发布','midware-release'),虽然我能够生成一个我可以在我的应用程序中使用的AAR文件,但应用程序无法找到依赖库项目的类,我必须将两个库项目的AAR添加到我的应用程序中.

这是app.gradle应用程序项目(无需手动添加JAR),无法找到依赖项目的类:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.app.sample"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies …
Run Code Online (Sandbox Code Playgroud)

dependency-management android-gradle-plugin aar

7
推荐指数
1
解决办法
8631
查看次数

android studio生成依赖的aar

我有一个库项目(A)引用另一个jar文件(B.jar),但是在生成aar文件之后,jar文件(B.jar)没有捆绑在输出aar文件中,当使用这个aar文件时,我得到了a NoClassDefFoundError.

有没有办法让gradle捆绑输出aar文件中的所有依赖类?这是我的build.gradle:

apply plugin: 'com.android.library'

repositories {
    mavenCentral()
}

android {

    buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':common')
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio

6
推荐指数
2
解决办法
1994
查看次数