1

I'm trying to get started with Bazel for compiling for Android, and I'm having some problems with my app UI - specifically, if I try to have a UI, Bazel chokes.

The main activity looks like this:

package org.mamizou.example.test
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
....
public class MainActivity extends AppCompatActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
    }
}

So according to android.developer.com, the right thing to do if I want to use appcompat-v7 is just in my android_library block, include "//external:android/appcompat_v7". Cool. My android_library block now looks like this:

android_library(
    name="lib",
    deps=[ "//external:android/appcompat_v7", ],
    srcs=[ "src/org/mamizou/example/test/ExampleLib.java", ],
)

Ok. Then I run bazel build, and I get

ERROR: missing input file '@android_sdk//:extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar"

If I go to my android-sdk directory to check it out, I notice that there's a path like android-sdk/extras/android/m2repository/com/android/support/appcompat-v7 but there's no path like android-sdk/extras/android/support

Using the SDK manager tool, I managed to flush my support repository and re-install it, but no change - my support files are all under m2repository. And they're *.aar files, not *.jar files. I can't find anything with a name like *appcompat.jar

So, something's wrong here. It smells like I've done something wrong with my environment configuration, but you've seen the relevant block of BUILD, and my WORKSPACE looks like this:

android_sdk_repository(
    name="android_sdk",
    path="/home/mamizou/android-sdk",
    api_level=23,
    build_tools_version="23.0.2",
)

which looks well-formed to me, at least (and more importantly, points to a real place where the sdk is installed)

  1. Why is Bazel looking for a *.jar in support, when it seems to me that Google's SDK indicates it should be looking for an *.aar under m2repository?
  2. What changes do I need to make so Bazel can find the relevant appcompat-v7 files?

fwiw, Bazel build label is 0.2.0-jdk7

  • `android_sdk_repository` basically symlinks to your `path` directory, so I assume the unexpected path is in /home/mamizou/android-sdk. How did you get android-sdk? (I'm guessing you downloaded it or built it using maven in some way?) – kris May 11 '16 at 16:57
  • Definitely didn't build it. I'm pretty sure that I got it using the Android SDK manager. Is that the best way to do it? – radiofreemyourenji May 12 '16 at 14:21

2 Answers2

1

The aar files are coming from "Android Support Repository" under Extras in the SDK manager. For the jars that bazel is using, you'll want to download "Android Support Library". Sorry for the confusion!

ahumesky
  • 4,203
  • 8
  • 12
  • You nailed it. I got confused by [the support library setup page](https://developer.android.com/tools/support-library/setup.html) and `if you're developing with Android Studio, select and install the Android Support Repository item instead.` I thought they were just explaining a naming difference, but they're two different things. Thanks! – radiofreemyourenji May 13 '16 at 20:21
0

Since Android Build tools 24 the "Android Support Library" have been removed:

Can't find Android Support Repository in SDK Manager

Community
  • 1
  • 1
jvmvik
  • 319
  • 1
  • 3
  • 9