简体   繁体   中英

How to import library to build.gradle

I'm trying to resolve some problem and I found old solution: Gradle build null console object

the problem is, the solution includes importing something in the gradle.

How to import for eg: import javax.swing.JOptionPanel ?

I have never imported anything in the build.gradle and I can't find examples with it.

Swing (and JavaFX) are used for Java Desktop applications.

So you can't use Java Swing on Android because Java Swing is not supported on Android. Android System has its own UI API framework already inbuilt and doesn't use Swing Library at all.

That said to import a Library into gradle you can follow these steps.

  1. In Android View, open build.gradle file (module app) 在此处输入图像描述

  2. Find the dependencies section towards the bottom of the file: you will note there are other libraries already imported for you.

在此处输入图像描述

  1. Add the library you need by following this format

implementation group: 'com.example.android', name: 'app-magic', version: '12.3'

  1. You can use Google to find the Library group, name and version:

Here are links that you may find useful

Add build dependencies

Maven Repository

Google's Maven Repository

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM