前言

内卷,TNND内卷。无处不在!客户卷老板,老板就卷我们,我们就卷食堂。老革命阴沟里翻船了。好久没搞安卓了,老板让写个Android程序播放海康威视摄像头的RTSP流。一顿猛搜找到方案:用libvlc(万能播放器VLC)的库。CPU的架构有:X84,ARM v7,ARM 64 V8等。设备是arm v7 a 的。Android studio老是在变呢,以前还是apk为主的发布方式,现在默认都不是了。类库的文件是arr格式的,第一次使用这玩意儿,网上的文章照抄不管用,编译时提示,arr文件找不到。总之一大堆坑。

故事(分享的知识)主体

1) 配置的正确写法:

 

plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.vlcapplication"
        minSdk 23
        targetSdk 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation files('libs/libvlc-armv7-3.1.5.aar')
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

网上文章一大半都是误导人的写了要依赖"libs"文件夹,文章里写的类似:

 

 实际现在已经改了需要这样:

sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }