Android Studio NDK开发环境配置--已验证

配置Android Studio NDK开发环境


Android Studio、jdk、ndk下载地址:
https://www.androiddevtools.cn/

1 Android Studio安装

个人环境软件版本选择:
Android Studio3.2.0
android-ndk-r14b
jdk1.8.0_51

2 环境配置

jdk的bin目录放入系统环境变量path路径
SDK Location:选择自己的android sdk、jdk、ndk目录
cMake

3 问题

搭建环境碰到不少问题,网上资源杂,真正能解决的方案不好找,记录一下,有时间再补充
(1)gradle

Plugin version(插件版本)Required Gradle version(gradle版本)
1.0.0 - 1.1.32.2.1 - 2.3
1.2.0 - 1.3.12.2.1 - 2.9
1.5.02.2.1 - 2.13
2.0.0 - 2.1.22.10 - 2.13
2.1.3 - 2.2.32.14.1+
2.3.0+3.3+
3.0.0+4.1+
3.1.0+4.4+
3.2.0+4.6+

墙问题,下载慢,根据版本对应自行下载,zip文件直接copy至C:\Users\yourname.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg
(2)build.gradle
build阶段,Running问题—修改gradle\build.gradle成以下:

buildscript {
    
    repositories {
        google()
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app\build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.ywl5320.nativeopengldemo"
        minSdkVersion 19 // 选择了android4.4
        targetSdkVersion 30 // 高兼容低,默认
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:+' // 去掉:后数字
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

(3)夜神模拟器
Android Studio自带AVD,电脑配置不行的,卡的飞起,利用夜神模拟器:
① 下载安装夜神模拟器
② 配置指令:

  • 将夜神模拟器安装目录Nox\bin ,与android sdk的\platform-tools配置到环境变量path路径
  • cmd
  • adb version与nox_adb version查看版本是否一致
  • 不一致导致无法link,将androidsdk下platform-tools下adb.exe拷贝至Nox\bin目录,复制两份,覆盖一份,重命名一份为nox_adb.exe并覆盖
  • 执行adb devices 出现List of devices attached
    127.0.0.1:62001 device即可
  • 被占用netstat -ano | findstr “5037” 将进程kill掉
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值