AndroidStudio解决External Libraries的缓存问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AndroidStudio解决External Libraries的缓存问题相关的知识,希望对你有一定的参考价值。

参考技术A 在网上查询总结以下三种方法:

1.清除所有缓存依赖库:rm -rf ~/.gradle/caches/
2.清除指定缓存依赖库:rm -rf ~/.gradle/caches/modules-2/files-2.1/指定依赖库文件夹
3.刷新缓存依赖库:使用命令行执行gradle任务追加--refresh-dependencies参数,如:./gradlew :app:assembleDebug --refresh-dependencies

jni/ndk: android studio external tool 自定义工具(Javah/ndk-build命令)

打开Android studio设置找到external tools :

android studio -> preference -> tools -> external tools

一、配置 javah 命令

配置如下:

//javah.exe的地址
Program:
$JDKPath$\\bin\\javah

//生成.h文件的路径指定在jni文件中,$FileClass$为源.java文件
Arguments:
-encoding UTF-8 -d ../jni -jni $FileClass$

//进行编译成.h文件的源.java文件目录
Working directory:
$ProjectFileDir$\\app\\src\\main\\java

$JDKPath$ 是在 Android Studio 中设置JDK目录位置
$ModuleFileDir$ 是module的根路径
$FileClass$ 是对应文件的类名

在这里插入图片描述

javah 帮助

> javah -h
用法: 
  javah [options] <classes>
其中, [options] 包括:
  -o <file>                输出文件 (只能使用 -d 或 -o 之一)
  -d <dir>                 输出目录
  -v  -verbose             启用详细输出
  -h  --help  -?           输出此消息
  -version                 输出版本信息
  -jni                     生成 JNI 样式的标头文件 (默认值)
  -force                   始终写入输出文件
  -classpath <path>        从中加载类的路径
  -cp <path>               从中加载类的路径
  -bootclasspath <path>    从中加载引导类的路径
<classes> 是使用其全限定名称指定的
(例如, java.lang.Object)

执行:

在这里插入图片描述

二、配置 ndk-build 命令

配置如下:

//ndk-build.cmd路径
Program:
$ModuleSdkPath$/ndk/ndk-build.cmd

//生成的.so文件存放位置
Arguments:
NDK_LIBS_OUT=$ProjectFileDir$\\app\\libs

//编译源文件的目录
Working directory:
$ProjectFileDir$\\app\\src\\main

$JDKPath$ 是在 Android Studio 中设置JDK目录位置
$ModuleFileDir$ 是module的根路径
$FileClass$ 是对应文件的类名

ndk-build帮助

> ndk-build -h
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -E STRING, --eval=STRING    Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  --no-silent                 Echo recipes (disable --silent mode).
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for x86_64-apple-darwin
Report bugs to <bug-make@gnu.org>

以上是关于AndroidStudio解决External Libraries的缓存问题的主要内容,如果未能解决你的问题,请参考以下文章

在android studio中找不到权限MANAGE_EXTERNAL_STORAGE

在Android Studio 的External Tools添加javap命令

jni/ndk: android studio external tool 自定义工具(Javah/ndk-build命令)

external是啥意思?怎么读?

unresolved external symbol的解决方法

4.XXE (XML External Entity Injection)