How to enable JAR in APK without Eclipse?

I support the Android app and do not use Eclipse. I do not use Eclipse. I use ant and build.xml and build.properties .

I have a .jar file in the libs / directory. My code compiles only dandy. But when I run it on the emulator, the APK output does not contain .jar, so I get the stack stack:

 ERROR/AndroidRuntime(470): java.lang.NoClassDefFoundError: com.google.ads.AdView 

my build.properties looks like this:

 jar.libs.dir=libs 

And the libs / directory contains my .jar file.

What should be in the build.xml file for the external .jar file to be included in the APK?

Edit: Theoretically, this answer should work, but it is not for me. Is it out of date? What gives? How to add external jar libraries to android project from command line

+4
source share
5 answers

Turns out I needed to update the version of ant that I used for version 1.8. During the compilation process, I received an error message:

Warning: the out.dex.jar.input.ref link was not set at run time, but was found while parsing the buildbuild file, trying to solve the problem. Future versions of Ant may support link identifiers defined for unfulfilled purposes.

I looked for it and found that I need to update Ant, and now I do not receive this warning, and my application does not force close.

+1
source

I just ran into a similar problem and noticed that libraries should not be placed in "myprojectdir \ lib". When I moved them to "myprojectdir \ libs" everything started to work.

+4
source

What should be in the build.xml file for the external .jar file to be included in the APK?

Just putting it in libs/ enough.

my build.properties looks like this:

This line is not needed. It does not appear in my build.properties files that work successfully with JAR files.

If you use dexdump -f classes.dex from your bin/ project, you can determine if he made com.google.ads.AdView there. If this is not the case, then something is strange with your build scripts. If so, then maybe there is a dependent JAR that you are missing (although I would expect VerifyError in this case).

0
source

You are using a third-party library, but you do not seem to be using DX. Make sure that not only your code is processed using the DX tool (I assume it is Ant), but also all the third-party libraries that you use. You can look in the 7Bee script I use to convert web applications to the Android davlik format, so it can work for you too. More information about the script can be found on the Atjeews page.

0
source

Decision:

  • right-click on the project in the project tree and select "Project" Properties
  • choose java build path
  • select TAB Order and Export
  • check out GoogleAdMobAdsSdk-4.0.4.jar (or your SDK version)
  • click OK
  • clear the project on the menu Project -> Clean
  • rebuild project (Project - Build Automatically)
0
source

All Articles