Android Studio使用另一个AAR文件和其中的jar创建AAR [英] Android Studio Create AAR using another AAR file and jar inside

查看:235
本文介绍了Android Studio使用另一个AAR文件和其中的jar创建AAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用另一个aar和jar文件依赖项来创建AAR文件。我已经成功创建了.aar发布文件。

I am creating AAR file using another aar and jar file dependency. I have successfully created the .aar release file.

然后,我将新的AAR文件导入了示例项目。该项目运行良好。当访问aar和jar类的含义时,它显示 NoClassDefFound 错误。

Then, I have imported my new AAR file into the sample Project. the project is running fine. when going to access that aar and jar classes mean, It's showing NoClassDefFound error.

注意:首先我想知道,到目前为止在另一个AAR内是否可行。有人可以帮我摆脱这个新事物吗?

Note: First I want to know, as of now AAR inside another AAR is possible or not. can anyone help me to come out from this new things issue?

我也提到了此链接创建包含多个AAR / JAR的AAR 。就是说transitive = true。但是,不知道在哪里使用该标志。在第三方中使用Application或在AAR项目依赖项内创建AAR时。

I referred to this link also Create an AAR with multiple AARs/JARs. It's saying transitive= true. But, not understand, where to use that flag. In third party using Application or while creating AAR inside AAR project dependencies.

感谢前进。

我的迷你项目Gradle文件:

My Mini Project Gradle File:

迷你项目,仅转换为.AAR文件。然后,此文件将仅使用另一个NewProject

Mini Project, which is only converting into .AAR file. then, this file only going to use another NewProject

Mini Project Build.gradle文件

Mini Project Build.gradle file

/*
This would be enabled for development purpose and to debug and check the same
*/

apply plugin: 'com.android.application'

/*
This would be enabled for exporting as aar file
apply plugin: 'com.android.library'
*/

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

android {

    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
    defaultConfig {

        /*
        This application id would be used for development purpose and to debug and check the same.
        This would be commented when exporting as library
        */
        applicationId 'com.pss.pssplayer'
        minSdkVersion 18
        targetSdkVersion 23
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
    }

    aaptOptions {
        cruncherEnabled = false
    }

    buildTypes {

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

        }
    }

    productFlavors {
    }
}

dependencies {

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

    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:23.1.1'

    compile 'com.android.support:support-v4:23.1.1'

    compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')

    compile files('libs/secure.jar')

    compile(project(':getSubProject')) {

        transitive = true

    }// this getSubProject also contains one classes jar
}


推荐答案

使用 android-fat-aar gradle插件,它非常有用!

Use android-fat-aar gradle plugin, it is super usefull!

这篇关于Android Studio使用另一个AAR文件和其中的jar创建AAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆