准备工作

所用软件

  • Windows 11 / Ubuntu 20.04
  • Android Studio 2020.3.1(当时的最新版)
  • NDK 17.2.4988734
  • Target SDK 27
  • Compile SDK 29.0.3
  • JDK 1.8
  • Gradle 7.2

所用硬件

  • 微软LifeCam摄像头
  • 绿联30176 USB-C转USB 2.0数据线
  • OPPO Find X3 Pro

检查手机是否支持UVC

找到Android的SDK安装位置,并找到 platform-tools\adb.exe 工具,在Windows Powershell终端中依次输入如下命令:

.\adb.exe shell
cd sys/bus/usb/drivers
ls

查看输出,如果输出中有uvcvideo则表示手机支持UVC摄像头。

代码下载

从项目地址下载源码。

项目设置

SDK国内源

将HTTP Proxy修改为 Auto-detect proxy settings,勾选 Automatic proxy configuration URL,并填入国内源地址,这里是

mirrors.dormforce.net:80


在Android SDK设置页面,勾选 Force https://… sources to fetched using http://

gradle 国内源

在 C:\Users\38325.gradle 文件夹下创建 init.gradle 文件。

输入如下内容:

allprojects{repositories {def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public'def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter'all { ArtifactRepository repo ->if (repo instanceof MavenArtifactRepository){def url = repo.url.toString()if (url.startsWith('https://repo1.maven.org/maven2')) {project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."remove repo}if (url.startsWith('https://jcenter.bintray.com/')) {project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."remove repo}}}maven {url ALIYUN_REPOSITORY_URLurl ALIYUN_JCENTER_URL}}
}

如果项目层的build.gradle文件内容如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {repositories {google()jcenter()}dependencies {classpath 'com.android.tools.build:gradle:3.5.1'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}allprojects {repositories {google()jcenter()}
}task clean(type: Delete) {delete rootProject.buildDir
}

将其修改如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {repositories {maven { url 'https://maven.aliyun.com/repository/google' }maven { url 'https://maven.aliyun.com/repository/public' }maven { url 'https://maven.aliyun.com/repository/jcenter' }}dependencies {classpath 'com.android.tools.build:gradle:3.5.1'// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}allprojects {repositories {maven { url 'https://maven.aliyun.com/repository/google' }maven { url 'https://maven.aliyun.com/repository/public' }maven { url 'https://maven.aliyun.com/repository/jcenter' }maven { url 'http://raw.github.com/saki4510t/libcommon/master/repository/' }}
}task clean(type: Delete) {delete rootProject.buildDir
}

NDK设置

在local.properties文件中添加ndk.dir变量,将其赋值为ndk路径,这里使用的是r17版本。

程序运行

错误处理

ndk-build.cmd’’ finished with non-zero exit value 2

较新版本的ndk不支持原来的ABI,需要将 libuvccamera\src\main\jni\Application.mk 文件中的 APP_ABI改为

APP_ABI := arm64-v8a armeabi-v7a

Failed to resolve: com.serenegiant:common

添加依赖项,使用BaseActivity提示错误,造成这个原因是lib依赖中使用的implementation依赖在其他包中是不对外开放的,改成api方式依赖即可。
即把 libuvccamera 和 usbCameraCommon 中的 build.gradle文件下的

implementation("com.serenegiant:common:${commonLibVersion}") {exclude module: 'support-v4'
}

修改为

api("com.serenegiant:common:${commonLibVersion}") {exclude module: 'support-v4'
}

ERROR: Failed to resolve: com.serenegiant:common:2.12.4

duplicate class

删除aar包中某些文件再打包成aar

Build Output 栏内汉字出现乱码

Android Studio Build Output 栏内汉字出现乱码的解决方案

WiFi 连接手机

Android Quick Tip - ADB over WiFi

闪退问题修复

Android UVC Camera 闪退问题修复

解决Android UVCCamera stopPreview 报错 崩溃 闪退 问题

参考链接

Android Studio SDK 使用国内镜像源在线安装
这可能是介绍 Android UvcCamera 最详细的文章了
android设备外接多个usb摄像头

Android Studio 编译 UVCCamera相关推荐

  1. Android Studio 编译: Program type already present: XXX 解决方案

    Android Studio 编译: Program type already present: XXX 解决方案 参考文章: (1)Android Studio 编译: Program type a ...

  2. Android Studio编译问题-Error:Could not find org.jetbrains.trove4j

    Android Studio编译问题-Error:Could not find org.jetbrains.trove4j 一般来说是AS加载各种包或者库时失败导致的,有可能是网络原因. 因此我们更换 ...

  3. 【错误记录】Android Studio 编译报错 ( Deprecated Gradle features were used in this build, making it incompat )

    文章目录 一.报错信息 二.解决方案 一.报错信息 使用 Android Studio 编译比较老的 Android 项目时 , 报如下错误 : FAILURE: Build failed with ...

  4. 【错误记录】Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. ② | 升级 Gradle 版本 )

    文章目录 一.报错信息 二.解决方案 解决 Could not determine java version from '11.0.8'. 问题 , 有两种方案 , 方案一 : Android Stu ...

  5. 【错误记录】Android Studio 编译报错 ( SDK location not found )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Android Studio 编译报错 : 首次打开别人的项目 , 经常性的报错 ; Could not determine the depende ...

  6. 【错误记录】Android Studio 编译报错 ( A problem occurred starting process ‘command ‘ninja.exe‘ ‘ )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Android Studio 编译报错 : FAILURE: Build failed with an exception.* What went ...

  7. 【错误记录】Android Studio 编译报错 ( Invalid Gradle JDK configuration found )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Android Studio 编译时提示 Invalid Gradle JDK configuration found 错误 ; 一般是打开一个新的 ...

  8. 【错误记录】Android Studio 编译报错 ( Gradle 下载错误导致 Failed to open zip file 报错 )

    文章目录 一.报错信息 二.解决方案 1.修改 gradle-wrapper.properties 配置 ( 失效解决方案 ) 2.手动干预 Gradle 目录 ( 推荐 ) 3.手动下载 Gradl ...

  9. 我的Android进阶之旅------解决Android Studio编译后安装apk报错:The APK file does not exist on disk...

    1.错误描述 今天用Android Studio编译应用后安装APK的时候,报错了,错误如下所示: The APK file build\outputs\apk\OYP_2.3.4_I2Base_64 ...

  10. Android Studio编译提示如下attribute layout_constraintBottom_toBottomOf (aka com.luck.pictureselector:layou

    1 问题 Android Studio编译提示错误如下 AAPT: error: attribute layout_constraintBottom_toBottomOf (aka com.luck. ...

最新文章

  1. 推荐两个Firefox插件
  2. 射雕三部曲的优美片段
  3. CSS学习笔记11 CSS背景
  4. 浅谈消息队列的原理及优势
  5. 教你用 Android 做二次开发,识别率达到科大讯飞语音输入水平 | 原力计划
  6. mt管理器显示java_真正免root的MT管理器详细使用教程
  7. c语言教材系统管理课设
  8. YAML文件格式详解
  9. edge同步chrome书签_如何通过 iCloud 同步 chromium edge 的书签?
  10. 短视频直播行业服务器选择
  11. java 核型技术 卷2 pdf,NGS-analysis/Structural-Variation.md at master · zhuhuo/NGS-analysis · GitHub...
  12. Python类和包的介绍
  13. MathType编辑双向斜箭头的教程
  14. iPhone12、iPhone12 Pro、iPhone12 Max、iPhone12 Pro Max 详细参数配置
  15. 《云计算与虚拟化分析》_2章:虚拟化技术
  16. 什么是千兆级LTE?带你了解5G网络之前最重要的通信创新
  17. Linux系统基础学习--ubuntu
  18. CSS 文字下划线间距
  19. week02--简略
  20. 面向高稳定,高性能之-Hbase数据实时同步到ElasticSearch(之二)

热门文章

  1. 紧急求救~~~在线等...请问asp怎么同时连接多个SQL SERVER数据库..小女子在此先谢谢了..
  2. BootstrapTable的列排序怎么搞
  3. windows开启网络共享
  4. 逆向教程-U3D游戏逆向分析(伊甸逆向分析)
  5. ios13 微信提示音插件_ios13微信提示音如何进行更改
  6. Fastboot刷机
  7. Linux系统(三) 系统基础
  8. css 字符间距,单词间距
  9. python 实现大鱼吃小鱼小游戏(课程作业)
  10. 竹笛的分类有哪些?来认识竹笛的大家族。