0

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 e.g.: import javax.swing.JOptionPanel ?

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

discCard
  • 421
  • 1
  • 5
  • 16

1 Answers1

0

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) enter image description here

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

enter image description here

  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

Tonnie
  • 4,865
  • 3
  • 34
  • 50