SoFunction
Updated on 2025-03-08

Introduction to the correct way to introduce jar packages in Android development

If the jar package is introduced in Android incorrectly, some strange errors will occur.
When working, there happened to be a jar package that needs to be called, and it took a long time to resolve the bug.
At the beginning, it was quoted like this (eclipse):
Right-click the project, Build path, java build path,
Select libraries, click "Add External JARs" in the button on the right,
Then choose the right jar package (most people should do this).
The console immediately reported an error: conversion to dalvik format failed with error 1.
And there will be a red cross on the project, although there are no errors in the project.
Clean, the project is normal, but the apk file and dex file in the bin are gone, and an error occurred when running the project: Can not find **.apk later found the reason because the method of importing the jar package is incorrect.

The correct method is as follows:
1. Right-click the project, Build path, java build path,
2. Select libraries and click "Add Library" in the button on the right.
3. Select "User library" and click "Next"
4. Click the "User libraries" button in the interface that appears to click the "New.." button <
Give it a random name in the pop-up interface and click "OK"
5. Click the "Add jars" button to select a third-party jar package.
Click "OK" to complete the operation. In this way, the jar package will be packaged into the apk together, and the problem will be solved!