简体   繁体   English

Android Studio导出jar不导出任何jar

[英]Android Studio Export jar not exporting any jar

I am fairly new to android studio, and I am trying to export a jar out of an Android Studio project for another Unity project. 我是android studio的新手,我正尝试将一个jar从Android Studio项目导出到另一个Unity项目。

I followed the instruction given on the link Create An Android Plugin For Unity Using Android Studio 我按照链接上的说明使用Android Studio创建Unity的Android插件

But whenever I'm trying to export its showing "Build Successful" and "External task execution finished 'exportJar'" but I am not able to find any jar in specified folder of gradle file. 但是,每当我尝试导出其显示为“ Build Success”和“ External Task Executive'exportJar”完成的显示时,我都无法在gradle文件的指定文件夹中找到任何jar。

I looked into the folders "app/release" its empty and "app/build/intermediates/bundles/release/" contains only another folder named "instant-run". 我查看了“ app / release”文件夹中的空白,而“ app / build / intermediates / bundles / release /”仅包含另一个名为“ instant-run”的文件夹。

So I am bit confused whether I am skipping any step or looking on the wrong path. 因此,我是跳过步骤还是在错误的路径上感到困惑。

I m using Android Studio v2.1.2 我正在使用Android Studio v2.1.2

App.build file App.build文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.merchantapp"
        minSdkVersion 8
        targetSdkVersion 19
    }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.2.1'
    compile files('libs/PGSDK_v1.0.jar')
    compile files('libs/classes.jar')
}
task deleteOldJar(type: Delete) {
    delete 'release/AndroidPlugin.jar'
}

//task to export contents as jar
task exportJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('release/')
    include('classes.jar')
    ///Rename the jar
    rename('classes.jar', 'AndroidPlugin.jar')
}

exportJar.dependsOn(deleteOldJar, build)


android {
    lintOptions {
        abortOnError true
    }
}

you should change this line 你应该改变这一行

apply plugin: 'com.android.application' 应用插件:“ com.android.application”

to

apply plugin: 'com.android.library' 应用插件:“ com.android.library”

it is mandatory. 这是强制性的。 and then rebuild your project. 然后重建您的项目。 cause we are generating library and it should required for build jar file. 因为我们正在生成库,所以构建jar文件需要它。 reference How to export library to Jar in Android Studio? 参考如何将库导出到Android Studio中的Jar?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM