Adding Android Support Libraries


(Matt Robertson) #1

I am working on an existing project developed by another developer. The project lists references for:

  • android
  • android-support-design
  • android-support-v4
  • android-support-v7-appcompat
  • cooper

Each reference (in Visual Studio 2015 or 2017) shows a yellow warning sign over the bullet point, and when I attempt to build the project I get “reference could not be resolved” errors on support-design, support-v4, and support-v7-appcompat. “CopyLocal” is set to true for each. I am guessing I need to manually download and reference the libraries? I have downloaded the libraries through the SDK Manager in Android Studio, and they are in the m2repository directory in sdk/extras/android. How do I point Visual Studio to the libraries?

(Matt Robertson) #2

I might have solved this. I opened up the project file in a text editor and found where the references are pointing to. Since the project was developed by another developer on his PC, they were not pointing to the same place on my PC. Not ideal for collaborative development. I manually copied the jar files out of the m2repository in my sdk and into the folder structure indicated by the project. (I assume I should be able to do this in Visual Studio but it crashes every time I try to “Add Reference” by right-clicking on References in the Solution Explorer.)

I say I might have solved it because when I ran the build it failed with several aapt errors about references already being defined. In Android Studio this is normally fixed with a project clean/rebuild, but cleaning and rebuilding in VS is not fixing the problem. So technically I was able to solve the “References” problem, but I am still unable to build with support libraries referenced.

(marc hoffman) #3

You will want to add these as Package References, see

(Matt Robertson) #4

Thanks Marc! This looks promising. I’m running into some problems implementing it though. I am unable to add any references through the Solution Explorer - VS crashes every time. When I manually add <GradleReference Include="" /> to the project file it notices the change and forces a restart of VS, but the reference is not picked up on restart.

For example, here is my old file (with direct references):

  <Reference Include="android-support-v4.jar">
    <HintPath>C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\appcompat\libs\android-support-v4.jar</HintPath>

And here is my new file (with package references):

  <GradleReference Include="" />

Am I implementing the package reference correctly? VS does not seem to recognize it.

(marc hoffman) #5


that looks correct, yeah. Can you send me the/a project in question that shows this. What happens if you build the modified project in Water or from the command line?

(Matt Robertson) #6

Sure thing. This is the default Android Application template with the only change being that Gradle Reference added in the project file. (35.4 KB)

(marc hoffman) #7

Hmm. that project and the package reference look good, and it builds here for me — but I’m only able to test on Mac right now, so I cannot speak for Visual Studio, which does handle things a bit differently (I can check there later, ion the below yields nothing). What build of Elements are you using? If you’re not already, can you try the latest beta (.2305), preferably, or at least the latest stable (.2293)?

What happens when you build the project form the command line via "ebuild \path\to\your\project.sln --debug"? Can you send me the full output?


(Matt Robertson) #8

I have not built with ebuild from the command line before so perhaps I’m missing something basic, but this is what I get…

RemObjects EBuild. An open source build engine for Elements and beyond.
Copyright RemObjects Software 2016-2018. All Rights Reserved. Created by marc hoffman.
Version (develop) built on bajor, 20180608-164532. Commit ce2eeea.

E: More than one project specified.

(marc hoffman) #9

whats your exact command line? note that if your project path has spaces, you’ll need to add quotes around it.

(Matt Robertson) #10

Good grief. I’m not at my computer any longer but I’m positive it’s the quotes thing because I copied the path out of Windows Explorer instead of navigating there from the cli. That explains the error though. I’ll post the real output when I run it.

(Matt Robertson) #11

Marc - I ran ebuild from the command line this morning and was given an error saying the version could not be found. I checked the m2repository and sure enough I was referencing a nonexistent revision. I changed this to a legitimate revision and it compiled without a problem from the command line. Here is the output if you’re interested. testout.txt (154.1 KB)

In VS the project builds successfully. I also tried adding a support library view element and was able to successfully build and run the project. For some reason though the support library is not listed in the References menu of the Solution Explorer.

(marc hoffman) #12


excellent. So all is good now, except the display in VS? I’ll log an issue with the VS tea\m for that. I assume this will report with the project you sent me earlier?

(RemObjects) #13

Thanks, logged as bugs://80568

(RemObjects) #14

bugs://80568 got closed with status fixed.