简体   繁体   English

使用Android Studio导出jar时没有jar文件

[英]There is no jar file when I use Android Studio to export jar

I followed this tutorial to export jar file for unity3d using and I referred this to solve my issue, however, I still can't find any jar file in the project, the release directory is empty. 我按照本教程使用导出用于unity3d的jar文件,并参考文件解决了我的问题,但是,我仍然在项目中找不到任何jar文件,发布目录为空。

My build.gradle: 我的build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    defaultConfig {
//        applicationId "com.aoshitang.demo"
        minSdkVersion 21
        targetSdkVersion 28
//        versionCode 1
//        versionName "1.0"
//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation files('libs/unityClasses.jar')
}

task clearJar(type: Delete) {
    delete 'release/AndroidSensorPlugin.jar'
}

task makeJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('release/')
    include('classes.jar')
    rename ('classes.jar', 'AndroidSensorPlugin.jar')
}

makeJar.dependsOn(clearJar, build)

And this is the result: 结果如下:

16:29:44: Executing task 'makeJar'...

Executing tasks: [makeJar]

:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:packageDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:generateDebugRFile UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:extractDebugAnnotations UP-TO-DATE
:app:mergeDebugConsumerProguardFiles UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:packageDebugAssets UP-TO-DATE
:app:packageDebugRenderscript NO-SOURCE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:transformNativeLibsWithSyncJniLibsForDebug UP-TO-DATE
:app:bundleDebugAar
:app:compileDebugSources UP-TO-DATE
:app:assembleDebug
:app:preReleaseBuild UP-TO-DATE
:app:compileReleaseAidl NO-SOURCE
:app:compileReleaseRenderscript
:app:checkReleaseManifest UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:packageReleaseResources
:app:processReleaseManifest
:app:generateReleaseRFile
:app:generateReleaseSources
:app:javaPreCompileRelease UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:extractReleaseAnnotations UP-TO-DATE
:app:mergeReleaseConsumerProguardFiles UP-TO-DATE
:app:mergeReleaseShaders UP-TO-DATE
:app:compileReleaseShaders UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:packageReleaseAssets UP-TO-DATE
:app:packageReleaseRenderscript NO-SOURCE
:app:processReleaseJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:app:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:app:compileReleaseNdk NO-SOURCE
:app:mergeReleaseJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:app:transformNativeLibsWithSyncJniLibsForRelease UP-TO-DATE
:app:bundleReleaseAar
:app:compileReleaseSources UP-TO-DATE
:app:mergeReleaseResources
:app:verifyReleaseResources
:app:assembleRelease
:app:assemble
:app:lint
Ran lint on variant debug: 0 issues found
Ran lint on variant release: 0 issues found
:app:generateDebugUnitTestSources UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:javaPreCompileDebugUnitTest UP-TO-DATE
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:processDebugUnitTestJavaRes NO-SOURCE
:app:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:testDebugUnitTest
:app:generateReleaseUnitTestSources UP-TO-DATE
:app:preReleaseUnitTestBuild UP-TO-DATE
:app:javaPreCompileReleaseUnitTest UP-TO-DATE
:app:compileReleaseUnitTestJavaWithJavac UP-TO-DATE
:app:processReleaseUnitTestJavaRes NO-SOURCE
:app:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease UP-TO-DATE
:app:testReleaseUnitTest
:app:test
:app:check
:app:build
:app:clearJar UP-TO-DATE
:app:makeJar NO-SOURCE

BUILD SUCCESSFUL in 6s
53 actionable tasks: 11 executed, 42 up-to-date
16:29:51: Task execution finished 'makeJar'.

I think I succeeded to export the jar file but there is empty in release directory, that's wired. 我想我已经成功导出了jar文件,但发布目录中没有空文件,即已连接。 By the way, I am using macOS Mojave 10.14 and my Android Studio version is 3.2. 顺便说一句,我正在使用macOS Mojave 10.14,而我的Android Studio版本是3.2。

Any help? 有什么帮助吗?

I figured it out. 我想到了。 Currently Android Studio do not put classes.jar in build/intermediates/bundles/release/ , it's in build/intermediates/packaged-classes/release/ . 目前,Android Studio尚未将classes.jar放置在build/intermediates/bundles/release/ ,而是将其放置在build/intermediates/packaged-classes/release/ So do it like this: 所以这样做:

task makeJar(type: Copy) {
    from('build/intermediates/packaged-classes/release/')
    into('release/')
    include('classes.jar')
    rename ('classes.jar', 'AndroidSensorPlugin.jar')
}

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

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