0

I have a class AplicacaoTeste with a main and I need to generate a .jar file, but I couldn't find anything to help me. How can I create a jar file and execute it on the teste.bat?

Imma post my project packages and build.gradle settings:

[project packages][https://i.stack.imgur.com/h5OGJ.png]

build.gradle

plugins {
    id 'com.android.application'
}

android {
    namespace 'aXX.es'
    compileSdk 33

    defaultConfig {
        applicationId "aXX.es"
        minSdk 24
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildscript {
        repositories {
            jcenter()
        }

        dependencies {
            classpath 'de.mobilej.unmock:UnMockPlugin:0.6.0'
        }
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

  • 2
    A gradle android project doesn't build JAR files, because Android doesn't run jar files (it runs APK files or DEX files, depending on which level you are looking at). If you want a classical Java jar file in an Android project, I suggest you separate that out into its own module (i.e. sub-project). That would also help with making the dependencies easier to separate, because having Android-specific dependencies in a jar file will likely make the jar file not work correctly. Also [this question](https://stackoverflow.com/q/21712714) might be useful. – Joachim Sauer Jan 25 '23 at 15:51

0 Answers0