Import Android Studio to Fresco and androidfresco
About a week ago, Facebook opened the image download and cache tool customized for the Android system. On that day, the message came to the headlines of major technology forums, it has also become the main topic discussed in various technical groups. In the same day, some people in the stay4it QQ Group tried to use Android Studio to import Fresco. After a long time, they still failed. In this case, more than one person encountered this problem, the Import fails and compilation fails, let alone running. Two days ago, I had a holiday during the Tomb Sweeping Day. I tried it with curiosity and found that it was really troublesome, But it finally succeeded in compiling and running. First, let's share the sample run and seduce everyone:
Now I will share my import process with you. I hope you will not take a detour. I have thought about adding another course in my Android Studio video series to explain the import of Fresco, but I want to write a blog and share it with you, the reason is that you can see it later.
First, introduce the system and environment of my computer:
- Macbook Pro
- Yousemite
- Android Studio 1.2 beta (the version has just been upgraded, and most people should still be in version 1.1)
- Gradle 2.2.1-all
In addition, you need to download the Android NDK in advance and configure the path of the Android NDK to the environment variable. I will not describe the specific download and configuration here, being a good programmer is not a problem. Remember FQ.
Zookeeper believes that most of my friends use Windows, but because I have abandoned Windows for too long, the Windows machine in my house has passed the tests, and I have been ill, so I have not tried it on Windows, however, from the perspective of Fresco issues on Github, there are still problems with Windows import. At least this article has not been resolved yet. Because Facebook teams are developed on Mac or Linux, they have not been tested on Windows, so various bugs may occur, here is an open issue for Windows on Github. You can refer to it or follow up it in real time.
Please refer to the following link for more information: How to import Fresco on Mac? First, clone Fresco from Github.I would like to remind you that FQ is the best throughout the import process, because some resources must be accessed by FQ during the import and subsequent build. In addition, the import and build process is time-consuming and requires a lot of related resources to be downloaded. Therefore, it is best to make sure that you try to import data when the network conditions are good. This is also the main reason why I have not recorded a video course.Open Android Studio, select Import Project,
Zookeeper selects the cloned Fresco path and click OK. The next step is a long download and import process,
Zookeeper is a long process. During this period, you can do something else, take a break in a game, or take a look At Fresco's Chinese documents. The main resources downloaded during the import process include:
When all your resources are downloaded to the main interface of Android Studio, you are half done. The next step is build,You must note that you can only build using the command line. You cannot use the build-> make project or rebuild project on the menu bar, because the latter build will fail.The following error occurs:
When the above error occurs, I also tried to search for a solution. On Github, there is such an article about [Mac import build issue]. someone mentioned that you want to build the imagepipeline module. the ndk paths in gradle are all allocated with your local absolute path. I tried it and failed. I will not post any specific errors. I think there are still bugs here, if you are interested, you can take a look at the mentioned issue.
Zookeeper since the GUI build is not successful, we can use the command line to build, open the terminal tab in the lower left corner of Android Studio, and check whether the terminal path is the root directory of the Fresco project, because gradlew and gradle wrapper are both under the root directory of the project. Run./gradlew clean to clean the project. You may encounter the following error:
Just remove the build folder in each module. In fact, the clean process is the same. After deletion, we can run./gradlew build. The entire build process can be divided into three phases:
After the three phases of zookeeper, your build should also be successful. The entire build process should be around 10 minutes, to be honest, I also saw this long build project for the first time. After the build is successful, it should be as follows:
Now that we have finished importing Fresco, congratulations on your success. Let's run it:
You can select a loading tool to download all images and gif images, and then switch to the loading tool for comparison,You will find that Fresco's cache loading efficiency is much higher than our commonly used picasso and imageloader, and the effect is too obvious.As for the download speed, I personally think the difference is not big. This is related to the network environment, even if the download speed in the same network environment is not big.
Zookeeper: this is the whole process of importing Fresco. It has limited time and general capabilities. If there is any explanation error or you have a better solution, please leave a message for us to discuss it.