IntelliJ Idea Android Projects including un-watned

2020-07-22 17:32发布

I have a complex app structure, main project has android libraries which have their own android libraries and jars.

Main Project

  • Libs
    • Android Lib project A
      • Jars
      • Android Lib project B
    • Jars

For clarification I have an android library project which has an ActionBarSherlock dependency and Facebook dependency, I use this library project between a few similar apps.

In the past I was able to just add the libraries as dependencies and it would build only the android related files (src/res) but now it is including everything in the path (tests, docs, example folders, websites).

I'm not sure what changed but my apks are now being stuffed with a lot of files I don't want and I'm not sure where to specify to not include them.

note: The reason why I can't just "remove" the unwanted files is because I'm cloning down the repos with submodules.

I'm using IntelliJ Idea 11.1.2 and android r20

Update: Here is a sample project of the problem I'm having: http://dl.dropbox.com/u/713581/TestDependency.zip

1条回答
我只想做你的唯一
2楼-- · 2020-07-22 17:50

This happens because you keep your modules in the directory named libs which is by default designed for the native libraries (usually .so files). When building the project all the files from the libs directory are included in the target apk file.

To fix the problem go to the Project Structure, select Test Dependency module, open Android facet settings, change Native libs directory setting to some other path (like libs_ instead of libs). Repeat the same for the TestLib module, rebuild the project. Now the final apk size is ~486KB and files from libs folders are not included.

Native libs directory

查看更多
登录 后发表回答