简体   繁体   中英

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.

I followed the instruction given on the link Create An Android Plugin For Unity Using Android Studio

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.

I looked into the folders "app/release" its empty and "app/build/intermediates/bundles/release/" contains only another folder named "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

App.build file

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'

to

apply plugin: 'com.android.library'

it is mandatory. and then rebuild your project. cause we are generating library and it should required for build jar file. reference How to export library to Jar in Android Studio?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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