参考 http://www.liaohuqiu.net/cn/posts/about-red-apricot-and-compiling-fresco/
1、准备工作 ,安装ndk 并设置环境变量 ~/.bash_profile
首先要 配置 android_home 和 ndk 环境变量
记住你下载的ndk版本 后面有用
我下载的是 11
mac 下在 ~/.bash_profile 中配置
export ANDROID_NDK_ROOT=/Users/zhou/Library/Android/NDK
export ANDROID_HOME=/Users/zhou/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_NDK_ROOT}
保存后 做下
$source ./bash_profile
或者重启让环境生效
2\下载 fresco 源码
website : https://github.com/facebook/fresco
https://github.com/facebook/fresco/archive/master.zip
3\解压缩 到自己的工作目录 fresco-master
4\ 进入fresco-master
运行
$./gradlew
就会显示:
==============
MacdeMac-mini:fresco-master zhoufuqiang$ ./gradlew
Download https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.0/jsr305-3.0.0.pom
Download https://jcenter.bintray.com/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.pom
Download https://jcenter.bintray.com/net/java/jvnet-parent/3/jvnet-parent-3.pom
Download https://jcenter.bintray.com/com/google/code/findbugs/jsr305/3.0.0/jsr305-3.0.0.jar
Download https://jcenter.bintray.com/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar
Download https://jcenter.bintray.com/org/easytesting/fest-assert-core/2.0M10/fest-assert-core-2.0M10.pom
Download https://jcenter.bintray.com/org/easytesting/fest/1.0.15/fest-1.0.15.pom
Download https://jcenter.bintray.com/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.pom
Download https://jcenter.bintray.com/org/powermock/powermock-api-mockito/1.6.2/powermock-api-mockito-1.6.2.pom
Download https://jcenter.bintray.com/org/powermock/powermock-api/1.6.2/powermock-api-1.6.2.pom
Download https://jcenter.bintray.com/org/powermock/powermock/1.6.2/powermock-1.6.2.pom
Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
Download https://jcenter.bintray.com/org/powermock/powermock-module-junit4-rule/1.6.2/powermock-module-junit4-rule-1.6.2.pom
Download https://jcenter.bintray.com/org/powermock/powermock-modules/1.6.2/powermock-modules-1.6.2.pom
Download https://jcenter.bintray.com/org/robolectric/robolectric/3.0/robolectric-3.0.pom
Download https://jcenter.bintray.com/org/robolectric/robolectric-parent/3.0/robolectric-parent-3.0.pom
Download https://jcenter.bintray.com/org/easytesting/fest-util/1.2.5/fest-util-1.2.5.pom
Download https://jcenter.bintray.com/org/objenesis/objenesis/2.1/objenesis-2.1.pom
Download https://jcenter.bintray.com/org/objenesis/objenesis-parent/2.1/objenesis-parent-2.1.pom
Download https://jcenter.bintray.com/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.pom
Download https://jcenter.bintray.com/org/powermock/powermock-api-support/1.6.2/powermock-api-support-1.6.2.pom
Download https://jcenter.bintray.com/org/powermock/powermock-classloading-base/
。。。。。。
BUILD SUCCESSFUL
===============
各种下载
5\然后在android 中打开此工程 open…
貌似很久 ,我用了一个晚上,如果网速快,会很好,也会各种下载
进行clean project 或者rebuild 或者运行时 会各种报错
============================================
以上只是步骤,以下是遇到的问题
问题 :
问题1
==========
* What went wrong:
A problem occurred configuring project ':drawee'.
> Failed to notify project evaluation listener.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
解决:
==========
需要设置 android_home 环境变量
问题二
==========
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':drawee'.
> Failed to notify project evaluation listener.
> failed to find Build Tools revision 23.0.0
> failed to find Build Tools revision 23.0.0
解决:
==========
需要下载build tools 23.0.0 ,不知到为啥要下载这个,更不知道为啥下载不下来
估计是要,你可以尝试去红杏出墙
或者 用一种智慧的方法
查看你本地已经安装的 build tools ,但最好要高于 他要求的23.0.0,比如我有23.0.2
那就修改fresco的配置文件
fresco-master/gradle.properties中的BUILD_TOOLS_VERSION
BUILD_TOOLS_VERSION=23.0.2
问题3
==========
如果 报错中有关于GRADLE_DOWNLOAD_TASK_VERSION 这个的
我把他修改成了
GRADLE_DOWNLOAD_TASK_VERSION=2.1.0
,随便改的 ,当时就过去了
文件位置同上
问题4
==========
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':imagepipeline:ndk_clean_bitmaps'.
> A problem occurred starting process 'command 'ndk-build''
解决:
==========
需要配置ndk
在imagepipeline中的gradle.properties 中配置
ndk.path=/Users/zhou/Library/Android/NDK
问题5
==========
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':static-webp:ndk_clean_static-webp'.
> A problem occurred starting process 'command 'ndk-build''
解决:
==========
需要配置ndk
在static-webp中的gradle.properties 中配置
ndk.path=/Users/zhou/Library/Android/NDK
问题6
==========
make: /Users/zhou/Library/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
make: /Users/zhou/Library/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
make: *** [/Users/zhou/Downloads/fresco-master/imagepipeline/build/tmp/ndk_build_bitmaps/local/armeabi-v7a/objs/bitmaps/Bitmaps.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [/Users/zhou/Downloads/fresco-master/imagepipeline/build/tmp/ndk_build_bitmaps/local/armeabi/objs/bitmaps/Bitmaps.o] Error 1
:imagepipeline:ndk_build_bitmaps FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':imagepipeline:ndk_build_bitmaps'.
> Process 'command '/Users/zhou/Library/Android/NDK/ndk-build'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
解决:
==========
这里就要用到刚才配置的ndk ,
根据上面宝错的提示
查看 ndk某目录下 的版本号
/Users/zhou/Library/Android/NDK/toolchains/arm-linux-androideabi-4.9
我的是4.9 ,报错的地方是4.8
在androidstudio 中全局搜索4.8 ,然后替换成4.9
/Users/zhou/Downloads/fresco-master/imagepipeline/src/main/jni/Application.mk 中
NDK_TOOLCHAIN_VERSION := 4.8
/Users/zhou/Downloads/fresco-master/static-webp/src/main/jni
NDK_TOOLCHAIN_VERSION := 4.8
都换成
NDK_TOOLCHAIN_VERSION := 4.9
然后
重新rebuild
问题7:
==========
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:25: 错误: 程序包android.support.test不存在
import android.support.test.InstrumentationRegistry;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:26: 错误: 程序包android.support.test.runner不存在
import android.support.test.runner.AndroidJUnit4;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:34: 错误: 程序包org.junit不存在
import org.junit.After;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:35: 错误: 程序包org.junit不存在
import org.junit.Before;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:36: 错误: 程序包org.junit不存在
import org.junit.Test;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:37: 错误: 程序包org.junit.runner不存在
import org.junit.runner.RunWith;
^
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:39: 错误: 找不到符号
@RunWith(AndroidJUnit4.class)
^
符号: 类 RunWith
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:44: 错误: 找不到符号
@Before
^
符号: 类 Before
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:86: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:103: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:123: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:138: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:158: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:170: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:183: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:195: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:208: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:222: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:238: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:249: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:260: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:276: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:292: 错误: 找不到符号
@Test
^
符号: 类 Test
位置: 类 WebpBitmapFactoryTest
/Users/zhou/Downloads/fresco-master/static-webp/src/androidTest/java/com/facebook/webpsupport/WebpBitmapFactoryTest.java:46: 错误: 找不到符号
mInstrumentation = InstrumentationRegistry.getInstrumentation();
^
符号: 变量 InstrumentationRegistry
位置: 类 WebpBitmapFactoryTest
24 个错误
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':static-webp:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
解决 :
==========
不知奥怎么解决的
clean 一下 ,在sdks中下载 android support library