Jar Dependencies (package does not exist) in Visua

2019-08-24 13:55发布

问题:

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:


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

  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.

回答1:

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