Android studio导入Netty

本文详细介绍如何在Android Studio中导入Netty库,包括通过Maven仓库获取不同版本的Netty jar包,以及使用Gradle配置实现自动化同步,确保项目无错误地引用Netty组件。

1.在Android Studio中需要导入jar包

maven下载地址,包括所有netty 版本:https://mvnrepository.com/artifact/io.netty/netty-all 
4.0.15: http://central.maven.org/maven2/io/netty/netty-all/4.0.15.Final/ 
git 源码地址:https://github.com/netty/netty/tree/netty-4.0.14.Final
jar下载地址:http://netty.io/downloads.html

2. gradle可以通过解析implementation的地址来获得正确的jar地址,在底层的gradle里修改为

buildscript {
 
    repositories {
        google()
        jcenter()
        maven{ url 'http://central.maven.org/maven2/'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
 
}
并且在app/gradle里添加

implementation group: 'io.netty', name: 'netty-all', version: '4.1.31.Final'
再次sync同步,ok,正确无报错。

在程序里import一下

import io.netty.
建议使用第二种方式简单便捷.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值