0

I'm facing an issue where I'm unable to use an external *.jar file in a "Visual C++" Android project in Visual Studio 2017 Community Edition.

When I try to compile it says the package android.support.design.widget does not exist.

Here is my setup:

enter image description here


Steps to reproduce

  1. Ensure you installed Visual Studio 2017 with Cross Platform Support and open it
  2. Choose "File"->"New"->"Project..."->"Basic Application (Android Ant)"->OK

enter image description here

  1. Add a libs folder to the project
  2. In the project.properties file add jar.libs.dir=libs
  3. Copy the file design-25.3.1-sources.jar from the android-sdk folder (for me it was under ...\android-sdk\extras\android\m2repository\com\android\support\design\25.3.1) to the libs project folder. If referencing would work even better. I haven't found a way yet.
  4. Add the import statement import android.support.design.widget.*; into the generated Activity.
  5. Hit F6 (Build Solution)

Results in the error described. Also Visual Studio 2015 had the same problem -> Jar Dependencies in Visual C++ Development in Visual Studio 2015

I'm looking for a way to use external libraries. Any idea what I could change?

Update July 10th 2017

I finally had to give up and change the build system from Ant to Gradle. With Gradle it is relatively easy to add libraries from the Android SDK. This is also the reason why I rate to close my question.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
  • Not sure if this is the problem but from what I see "design-25.3.1-sources.jar" isn't a compiled library even though it has a ".jar" file extension. It's just a bunch of .java (source code) files that has been zipped together. My understanding is that javac will not treat it as source code if you add it that way. Instead you'd probably have to extract the code you need out of it and reference it directly. – ackh May 29 '17 at 15:59
  • I found this way to approach it: https://stackoverflow.com/a/33117095/1306012 – Bruno Bieri May 30 '17 at 11:56
  • See update: I had to switched from `ANT` to `Gradle`. – Bruno Bieri Jul 10 '17 at 10:48

1 Answers1

0

The only way I could solve it was by switching the build system from ANT to Gradle.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92