Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rules_kotlin don't work #203

Closed
salim-boudriiya opened this issue Sep 23, 2019 · 6 comments
Closed

rules_kotlin don't work #203

salim-boudriiya opened this issue Sep 23, 2019 · 6 comments

Comments

@salim-boudriiya
Copy link

salim-boudriiya commented Sep 23, 2019

Hi @mig35 ,

I am working on a project, and I need to build an andoird project, written with kotlin in bazel, but I am finding several problems when making the construction, since I don't know how to attach the resources (res) and the AndroidManifest.xml file inside of the kt_jvm_library macro.

Please, can you help me to do this construction

Regards

Salim

@salim-boudriiya
Copy link
Author

My build file:

load("@gmaven_rules//:defs.bzl", "gmaven_artifact")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library")

MANIFEST = "AndroidManifest.xml"

android_binary(
name = "appsimpleandroid",
manifest = MANIFEST,
multidex = "native",
dex_shards = 10,
deps = [
"src"
]
)

kt_android_library(
name = "src",
custom_package = PACKAGE,
manifest = MANIFEST,
srcs = glob(["java/com/example/appsimpleandroid/MainActivity.kt"]),
resource_files = glob(["res/**"]),
deps = [
gmaven_artifact("androidx.appcompat:appcompat:aar:1.0.0-beta01"),
gmaven_artifact("androidx.constraintlayout:constraintlayout:aar:1.1.2"),

    # The following are transitive dependencies of the above
    gmaven_artifact("androidx.annotation:annotation:1.0.0-beta01"),
    gmaven_artifact("androidx.fragment:fragment:aar:1.0.0-beta01"),
    gmaven_artifact("androidx.lifecycle:lifecycle-common:2.0.0-beta01"),
    gmaven_artifact("androidx.lifecycle:lifecycle-viewmodel:aar:2.0.0-beta01"),
    gmaven_artifact("androidx.core:core:aar:1.0.0-beta01"),
    gmaven_artifact("androidx.drawerlayout:drawerlayout:aar:1.0.0-beta01")
]

)

@salim-boudriiya
Copy link
Author

Workspace File:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

android_sdk_repository(
name = "androidsdk",
path ="/Users/smba/Library/Android/sdk",
api_level = 28,
build_tools_version = "28.0.3"
)

http_archive(
name = "rules_android",
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
strip_prefix = "rules_android-0.1.1",
)

rules_kotlin_version = "f7a3b5fd823c2418fc2c2881c00e27e4d63475d5"
rules_kotlin_compiler_release = {
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v1.2.70/kotlin-compiler-1.2.70.zip",
],
"sha256": "a23a40a3505e78563100b9e6cfd7f535fbf6593b69a5c470800fbafbeccf8434",
}

http_archive(
name = "io_bazel_rules_kotlin",
urls = ["https://github.com/globegitter/rules_kotlin/archive/%s.zip" % rules_kotlin_version],
type = "zip",
strip_prefix = "rules_kotlin-%s" % rules_kotlin_version,
sha256 = "716127f93bfb09c577712c049b0812640f293362db2714489b78cb231c020a29",
)

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
kotlin_repositories()
kt_register_toolchains()

@salim-boudriiya
Copy link
Author

ERROR: /Users/smba/repo/Android/AppSimpleAndroid/app/src/main/BUILD:15:1: Validating Android resources for //AppSimpleAndroid/app/src/main:src_base failed (Exit 1) ResourceProcessorBusyBox failed: error executing command bazel-out/host/bin/external/bazel_tools/src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox --tool VALIDATE -- --buildToolsVersion 28.0.3 --aapt ... (remaining 16 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Sep 23, 2019 10:44:55 AM com.google.devtools.build.android.AndroidManifest parseFrom
WARNING:
CONFIGURATION: bazel-out/android-armeabi-v7a-fastbuild/bin/AppSimpleAndroid/app/src/main/src_base_processed_manifest/AndroidManifest.xml has no minSdkVersion. Using 1.
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:17: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:19: error: Error: No resource found that matches the given name: attr 'colorAccent'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:18: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:20: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Dark.ActionBar'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:26: error: Error: No resource found that matches the given name: attr 'windowActionBar'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:25: error: Error: No resource found that matches the given name: attr 'windowNoTitle'.
Error:
Error: /var/folders/tx/9n9trqnx7hb90g4bk6czbyrxbn6n7b/T/resource_validator_tmp2793367887449598481/tmp-expanded/res/values/values.xml:28: error: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Light'.

@mig35
Copy link
Contributor

mig35 commented Sep 23, 2019

Hey @salim-boudriiya
I'm not responsible for bazelbuild, but I've made a fork of this rules that you can find here: https://github.com/scalio/rules_kotlin and an example project for this rules: https://github.com/scalio/Android-Bazel-Starter-Kotlin

Also there is a good fork from @cgruber here:

Please select one of this repo and see example project and correct your rules.

Also kt_android_library doesn't have manifest or any other fields like res, etc. You should combine your code. See the example here

@salim-boudriiya
Copy link
Author

Hi Mihail,

thank you very much for your help.

Regards,

@cgruber
Copy link
Collaborator

cgruber commented Oct 3, 2019

As a quick update, per #159, github.com/cgruber/rules_kotlin (which works today with 1.3) will be merged into this repository, and I'll be helping maintain this one (taking appropriate changes here, and generally making this set of rules useful until we get the set of rules they're using inside google ready for open-source). Expect to see a working version of these rules within a few days from now.

@cgruber cgruber closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants