|
1 | | -# Prefab Samples |
| 1 | +# Sample removed |
2 | 2 |
|
3 | | -The samples in this directory demonstrate how to create and consume |
4 | | -[C/C++ dependencies] with the Android Gradle Plugin. Dependencies are packaged |
5 | | -within AARs using the [Prefab] package format. The Android Gradle Plugin |
6 | | -natively supports producing and consuming these, so you do not need to worry |
7 | | -about the details of the packaging format. |
| 3 | +The samples that used to reside in this directory have been removed. The |
| 4 | +behaviors demonstrated here (publication and consumption of AARs with native |
| 5 | +APIs) are now used throughout the samples for code sharing, and were Android |
| 6 | +Gradle Plugin features rather than NDK features. |
8 | 7 |
|
9 | | -The individual samples will explain in more detail, but the typical workflow for |
10 | | -a consumer of a native dependency is: |
| 8 | +For an example of how to create an AAR that exposes a native library, see the |
| 9 | +`base` module, or any other with `buildFeatures { prefabPublishing = true }`. |
11 | 10 |
|
12 | | -1. Enable the prefab build feature in your `build.gradle` file. |
13 | | -1. Add the dependency to the dependencies block of your `build.gradle` file. |
14 | | -1. Import the package in your `CMakeLists.txt` or `Android.mk` file. |
15 | | -1. Link the dependencies to your libraries. |
| 11 | +For examples of how to consume native APIs from an AAR, see any of the other |
| 12 | +samples which set `buildFeatures { prefab = true }`. |
16 | 13 |
|
17 | | -Linking the dependency to your library will automatically make the headers |
18 | | -available, link the required libraries, and include the dependencies you use in |
19 | | -your application or library. |
20 | | - |
21 | | -To produce an AAR that exposes C/C++ APIs: |
22 | | - |
23 | | -1. Enable the `prefabPublishing` build feature in your `build.gradle` file. |
24 | | -1. Use `android.prefab` in your `build.gradle` file to declare the names of the |
25 | | - libraries you wish to export and the headers that define their interface. |
26 | | - |
27 | | -To test your packages, follow the steps for package consumers. Note that until |
28 | | -https://issuetracker.google.com/120166563 is fixed it is not possible to depend |
29 | | -on the native components of an AAR generated by another module of the same |
30 | | -project when using Android Studio. Instead, test in a separate project. You can |
31 | | -import the AAR into your test project either |
32 | | -[directly](https://developer.android.com/studio/projects/android-library#AddDependency) |
33 | | -or by publishing it to a Maven repository. |
34 | | - |
35 | | -With that in mind, the samples here collectively demonstrate prefab usage: |
36 | | - |
37 | | -- prefab-publishing shows how to create an AAR for distributing native libraries |
38 | | -- prefab-dependency shows how to import native dependencies from [GMaven] |
39 | | -- curl-ssl: for shows to use 2 very specific and important AARs (curl and ssl) |
40 | | - |
41 | | -## Prefab Availability |
42 | | - |
43 | | -Support for Prefab packages has been available Android Gradle Plugin since |
44 | | -version 4.0: |
45 | | - |
46 | | -- Consuming native dependencies requires AGP 4.0+ |
47 | | -- Generating AARs that export native dependencies requires AGP 4.1+ |
48 | | - |
49 | | -The AARs used by the samples here are hosted at [Google Maven], but you can host |
50 | | -your AARs anywhere accessible to gradle. |
51 | | - |
52 | | -## Pre-requisites |
53 | | - |
54 | | -- Android Gradle Plugin 4.0+ |
55 | | -- The [Android NDK](https://developer.android.com/ndk/) |
56 | | - |
57 | | -Please check for the individial sample's README.md for anything specific to that |
58 | | -sample. |
59 | | - |
60 | | -## Support |
61 | | - |
62 | | -If you've found an error in these samples, please |
63 | | -[file an issue](https://github.com/android/ndk-samples/issues/new). |
64 | | - |
65 | | -Patches are encouraged, and may be submitted by |
66 | | -[forking this project](https://github.com/android/ndk-samples/fork) and |
67 | | -submitting a pull request through GitHub. Please see |
68 | | -[CONTRIBUTING.md](../CONTRIBUTING.md) for more details. |
69 | | - |
70 | | -- [Stack Overflow](http://stackoverflow.com/questions/tagged/android-ndk) |
71 | | -- [Android Tools Feedbacks](http://tools.android.com/feedback) |
72 | | - |
73 | | -## License |
74 | | - |
75 | | -Copyright 2020 Google, Inc. |
76 | | - |
77 | | -Licensed to the Apache Software Foundation (ASF) under one or more contributor |
78 | | -license agreements. See the NOTICE file distributed with this work for |
79 | | -additional information regarding copyright ownership. The ASF licenses this file |
80 | | -to you under the Apache License, Version 2.0 (the "License"); you may not use |
81 | | -this file except in compliance with the License. You may obtain a copy of the |
82 | | -License at |
83 | | - |
84 | | -http://www.apache.org/licenses/LICENSE-2.0 |
85 | | - |
86 | | -Unless required by applicable law or agreed to in writing, software distributed |
87 | | -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
88 | | -CONDITIONS OF ANY KIND, either express or implied. See the License for the |
89 | | -specific language governing permissions and limitations under the License. |
90 | | - |
91 | | -[c/c++ dependencies]: https://developer.android.com/studio/build/native-dependencies?buildsystem=cmake&agpversion=4.0 |
92 | | -[gmaven]: (https://maven.google.com/web/index.html?q=ndk#com.android.ndk.thirdparty) |
93 | | -[google maven]: https://maven.google.com/web/index.html#com.android.ndk.thirdparty |
94 | | -[prefab]: https://google.github.io/prefab |
| 14 | +See https://developer.android.com/build/native-dependencies for the Android |
| 15 | +Gradle Plugin's documentation of these features. |
0 commit comments