pubref / rules_kotlin

Bazel rules for Kotlin
Other
159 stars 20 forks source link

Add `kotlin_android_library` macro #32

Closed fishy closed 7 years ago

fishy commented 7 years ago

The current kotlin_library macro has a problem with AAR libraries when generating the implicated name.jar file. This new kotlin_android_library rule fixed it.

The documentation is also updated.

https://github.com/fishy/notifbot/tree/kotlin is a working example.

pcj commented 7 years ago

Nice!

pcj commented 7 years ago

@fishy can you clarify how I satisfy the support library dependencies for notifbot? Trying to compile your app:

pcj:~/github/fishy/notifbot/android*kotlin$ bazel build :app 
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:appcompat-v7-25.3.1': target 'appcompat-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'appcompat-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot_aar'
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:cardview-v7-25.3.1': target 'cardview-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'cardview-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot_aar'
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:recyclerview-v7-25.3.1': target 'recyclerview-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'recyclerview-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot_aar'
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:appcompat-v7-25.3.1': target 'appcompat-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'appcompat-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot'
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:cardview-v7-25.3.1': target 'cardview-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'cardview-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot'
ERROR: /Users/pcj/github/fishy/notifbot/android/BUILD:17:1: no such target '@androidsdk//com.android.support:recyclerview-v7-25.3.1': target 'recyclerview-v7-25.3.1' not declared in package 'com.android.support' (did you mean 'recyclerview-v7-25.0.1'?) defined by /private/var/tmp/_bazel_pcj/0542ecb82494809edb66a176e8accee0/external/androidsdk/com.android.support/BUILD and referenced by '//:notifbot'
fishy commented 7 years ago

You can change all "25.3.1" into "25.0.1" and that should work, too. It's not like I used any new feature in 25.3.1, I just tried to use the newest version available.

It's not very obvious to me which packages in Android SDK provided the version 25.3.1 of the support libraries. Probably "Android SDK Platform 25, rev3"? Try update your Android SDK packages :)

pcj commented 7 years ago

OK thanks, I'll try that. Seems like there could be a bazel android repository rule that interacts with ANDROID_HOME/tools/bin/sdkmanager and gets things installed automatically (? @ahumesky)

fishy commented 7 years ago

I did some test, the package is "extras;android;m2repository" with version number "47.0.0". Since you have 25.0.1, I guess you have that package, but it's not the newest version. Try update that package in your Android SDK :)

pcj commented 7 years ago

Tested, looks good.

Thanks for this awesome contribution @fishy, this is a real leap forward in terms of making bazel enjoyable with android.