The correct way to introduce the jar package in Andriod development

  • 2020-05-10 18:50:31
  • OfStack

If the jar package is introduced in the wrong way in andriod, some strange errors will occur.
There was one jar package that needed to be called while working, and it took a long time to resolve the bug that appeared.
Here is the original quote (eclipse) :
Right click engineering, Build path,java build path,
Select libraries and click "Add External JARs" in the button on the right.
Then select the appropriate jar package (which most people should do).
The console immediately reported an error: conversion to dalvik format failed with error 1.
There is also a Red Cross on the project, although there are no errors in the project.
Under clean1, the project is normal, but the apk file and dex file in bin are missing, and there is an error in running the project: Can not find **.apk later found that the reason was that the jar package was imported in the wrong way.

The correct way is as follows:
1. Right-click engineering, 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 step"
4. Click "User librarys" button and click "New.." in the interface that appears. button <
Choose a name in the popup screen and click "ok"
5. Click "Add jars" button to select the 3rd party jar package,
Click "ok" to complete the operation. In this case, the jar package will be packed into the apk by 1 unit, and the problem will be solved!


Related articles: