代码之家  ›  专栏  ›  技术社区  ›  OtakuFitness

使用androidstudio导出jar时没有jar文件

  •  2
  • OtakuFitness  · 技术社区  · 6 年前

    tutorial 要导出unity3d的jar文件,请使用 this 然而,为了解决我的问题,我仍然在项目中找不到任何jar文件,发布目录是空的。

    我的身材。格拉德尔:

    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)
    

    结果是:

    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'.
    

    有什么帮助吗?

    1 回复  |  直到 6 年前
        1
  •  9
  •   OtakuFitness    6 年前

    我想出来了。目前Android Studio没有将classes.jar放入 build/intermediates/bundles/release/ ,在里面 build/intermediates/packaged-classes/release/ . 所以就这样做:

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