How to use Android Studio (vi)-android Studio how to load. So files

Source: Internet
Author: User


I haven't been paying much attention before, thinking that. so files are loaded directly like eclipse, but until yesterday when I debugged the company project push message on Android studio, I discovered that the. so file was not loaded successfully.

Possible previous experience with Android Studio (iii)-Migrating from Eclipse to Android this article I use Demo4 to do an example, there is no reference to the. so file, so when you follow this article to move the project, you will encounter problems. Yesterday I looked online for an article about Android studio Gradle loading. So files, and found that most of the solutions that still stay in the gradle are very complex, and now the Android studio1.0 solves this problem in a very simple way! If you're still using a 1.0-year-old version, then I'm going to squirt your face.

Let me start by mentioning that if you create a project directly from Android Studio and migrate from Eclipse, the directory structure will be slightly different.

1. Let me start by talking about how to resolve the code that was migrated from Eclipse to load the. so file. Just take my project for example.

Check the directory structure first

You will notice that the project we migrated from Eclipse will default to us to create a folder Jnilibs, and then copy the contents of the Libs folder in Eclipse, and if you create the project directly in Android Studio, there will be no such folder. This is the difference one. On projects migrated from Eclipse, a configuration is added to the Build.gradle configuration file.

sourcesets {
Main {
Manifest.srcfile ' Androidmanifest.xml '
Java.srcdirs = [' src ']
Resources.srcdirs = [' src ']
Aidl.srcdirs = [' src ']
Renderscript.srcdirs = [' src ']
Res.srcdirs = [' res ']
Assets.srcdirs = [' Assets ']
Jnilibs.srcdirs = [' libs ']//This line is not, if we have. So files need to add this line of code
}

Move the tests to Tests/java, tests/res, etc ...
Instrumenttest.setroot (' tests ')

Move the build types to build-types/<type>
For instance, Build-types/debug/java, Build-types/debug/androidmanifest.xml, ...
This moves them out of them default location under src/<type>/... which would
Conflict with src/being used by the main source set.
Adding New build types or product flavors should be accompanied
by a similar customization.
Debug.setroot (' Build-types/debug ')
Release.setroot (' Build-types/release ')
}

Look at one more. I've always thought that compile Filetree (dir: ' Libs ', include: ' *.jar ') will load all of the. jar and. So files, but I was wrong, if not in the Sourcesets main inside add a sentence Jnilibs.srcdirs = [' Libs '], the. So file is not loaded.

2. If we create a project that is created on Android studio

There is no Jnilibs folder by default. So we need to create it ourselves. Catalogue Src->main->jnilibs

To load the loaded carrier pigeon SDK as an example

Let's copy all of the. so files to the Jnilibs file first. The directory does not change,

Last Added success

Then, again, add the. jar package. Like Eclipse, first put the. jar file in the Libs directory, and add Aslibrary.

Run the project and it's OK. There is no need to configure

Jnilibs.srcdirs = [' Libs ']

0You may also like:
    • Android Studio Usage tips (iv)---Android Studio multi-channel packaging
    • Android Studio user Experience (ii)---packaging signature apk release
    • Android Studio Experience (iii)---Migrating from Eclipse to Android studio
    • Android Studio Usage tips (a)---Android Studio quick master shortcut keys
    • Android Studio Usage tips (iv)---Android Studio multi-channel packaging (II)

How to use Android Studio (vi)-android Studio how to load. So files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.