4

So, the title pretty much sums up my problem. Anyone know how to fix it? Last time I build apk, it work fine on AS 2.X, but, I'm now developing with Kotlin so, I have to use AS 3.0.

I use AS 3.0 Canary 7 (This project is a fresh project)

This is my dummy class in my library (Stored in "domain".library.mylibrary)

class Test {
    fun hello(): String {
        return "hello"
    }
}

And this is my (mylibrary) gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"


    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        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(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
    testImplementation 'junit:junit:4.12'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //Declared in project level gradle: ext.kotlin_version = '1.1.3-2'
}

My gradlew.bat clean build --info log: https://pastebin.com/bfTZ5s4e

Moses Aprico
  • 1,951
  • 5
  • 30
  • 53
  • Where is your class stored. Post the whole path (relative to your project) – guenhter Jul 21 '17 at 05:42
  • Also run the command `./gradlew clean build --info` and append the log please. – guenhter Jul 21 '17 at 05:42
  • @guenhter ok wait – Moses Aprico Jul 21 '17 at 05:47
  • @MosesAprico Also replace `compile` to `implementation` in dependencies – DeKaNszn Jul 21 '17 at 05:50
  • @guenhter gradlew.bat is automatically closed when finished. How to retain it? – Moses Aprico Jul 21 '17 at 05:54
  • @MosesAprico you should run it via `cmd` (I guess you use Windows). So open `cmd` and navigate to your project. Than call it with `gradlew.bat clean build --info`. The output will remain in your `cmd`-session – guenhter Jul 21 '17 at 06:09
  • @guenhter done. please check my edit. – Moses Aprico Jul 21 '17 at 06:19
  • @guenhter weird, the aar is now shows up. i tried to clean project > make project from AS to test it once again, but the output doesn't re-shows up. If I choose rebuild project, it's now shows up again. Is this an intended behavior? – Moses Aprico Jul 21 '17 at 06:23
  • I just ran into this with the release version of AS3.0. I can build the AAR from the CLI using gradlew but for the life of me can't figure out how to build it from the GUI. – Zsombor Nov 11 '17 at 03:41

1 Answers1

0

Android Studio does not generate a jar by default, but rather an AAR file. If you want to get a jar output, you need to implement apply plugin: 'maven-publish' on top of your mylibrary/gradle.build file and read the following document: Chapter 36. Maven Publishing (new)

Another note, is that I would suggest you not to use ProGuard directly on your release artifact, but rather provide a consumer ProGuard file and let the users of your library to handle that task, otherwise they will have a hard time referencing obfuscated code. Read my answer on this here

While the build task may generate an output, it is known that the assemble task (or assembleRelease) is the one that will generate your aar output.

Try running the following command:

./gradlew clean assembleRelease

and check the output in /mylibrary/build/outputs/apk/release/ if I am not mistaken.

anthonymonori
  • 1,754
  • 14
  • 36