简体   繁体   English

如何将库导入 build.gradle

[英]How to import library to build.gradle

I'm trying to resolve some problem and I found old solution: Gradle build null console object我正在尝试解决一些问题,但我找到了旧的解决方案: Gradle build null console object

the problem is, the solution includes importing something in the gradle.问题是,解决方案包括在 gradle 中导入一些东西。

How to import for eg: import javax.swing.JOptionPanel ?如何导入例如: import javax.swing.JOptionPanel

I have never imported anything in the build.gradle and I can't find examples with it.我从来没有在build.gradle中导入任何东西,我找不到它的例子。

Swing (and JavaFX) are used for Java Desktop applications. Swing(和 JavaFX)用于 Java 桌面应用程序。

So you can't use Java Swing on Android because Java Swing is not supported on Android. 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. Android 系统有自己的 UI API 框架已经内置并且根本不使用 Swing 库。

That said to import a Library into gradle you can follow these steps.也就是说,要将库导入 gradle,您可以按照以下步骤操作。

  1. In Android View, open build.gradle file (module app)在Android视图中,打开build.gradle文件(模块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'实现组: 'com.example.android',名称: 'app-magic',版本: '12.3'

  1. You can use Google to find the Library group, name and version:您可以使用 Google 查找库组、名称和版本:

Here are links that you may find useful以下是您可能会发现有用的链接

Add build dependencies添加构建依赖项

Maven Repository Maven 存储库

Google's Maven Repository谷歌的 Maven 存储库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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