Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 83c6bf5

Browse files
Cleans up examples.
Improve README Remove call to app_dummy. Updates examples to 2018 edition.
1 parent 611c140 commit 83c6bf5

File tree

19 files changed

+64
-67
lines changed

19 files changed

+64
-67
lines changed

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ with the regular `cargo build`.
5050

5151
This will build an Android package in `target/android-artifacts/<debug|release>/apk`.
5252

53+
### Compiling Multiple Binaries
54+
55+
`cargo apk build` supports building multiple binaries and examples using the same arguments as `cargo build`. It will produce an APK for each binary.
56+
57+
Android packages for bin targets are placed in `target/android-artifacts/<debug|release>/apk/examples`.
58+
Android packages for example targets are placed in `target/android-artifacts/<debug|release>/apk/examples`.
59+
5360
### Testing on an Android emulator
5461

5562
Start the emulator, then run:
@@ -110,16 +117,16 @@ build_targets = [ "armv7-linux-androideabi", "aarch64-linux-android", "i686-linu
110117
package_name = "rust.cargo.apk.advanced"
111118

112119
# The user-friendly name for your app, as displayed in the applications menu.
113-
label = "Advanced android-rs-glue example"
120+
label = "My Android App"
114121

115122
# Path to your application's res/ folder.
116-
res = "res"
123+
res = "path/to/res_folder"
117124

118125
# Virtual path your application's icon for any mipmap level.
119126
icon = "@mipmap/ic_launcher"
120127

121128
# Path to the folder containing your application's assets.
122-
assets = "assets"
129+
assets = "path/to/assets_folder"
123130

124131
# If set to true, makes the app run in full-screen, by adding the following line
125132
# as an XML attribute to the manifest's <application> tag :
@@ -144,6 +151,11 @@ opengles_version_minor = 2
144151
"android:screenOrientation" = "unspecified"
145152
"android:uiOptions" = "none"
146153

154+
# Adds a uses-feature element to the manifest
155+
# Supported keys: name, required, version
156+
# The glEsVersion attribute is not supported using this section.
157+
# It can be specified using the opengles_version_major and opengles_version_minor values
158+
# See https://developer.android.com/guide/topics/manifest/uses-feature-element
147159
[[package.metadata.android.feature]]
148160
name = "android.hardware.camera"
149161

@@ -152,15 +164,14 @@ name = "android.hardware.vulkan.level"
152164
version = "1"
153165
required = false
154166

155-
# Request permissions. Note that android_version 23 and higher, Android requires the application
156-
# to request permissions at runtime. There is currently no way to do this using a pure NDK based application.
167+
# Adds a uses-permission element to the manifest.
168+
# Note that android_version 23 and higher, Android requires the application to request permissions at runtime.
169+
# There is currently no way to do this using a pure NDK based application.
170+
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
157171
[[package.metadata.android.permission]]
158172
name = "android.permission.WRITE_EXTERNAL_STORAGE"
159173
maxSdkVersion = "18"
160174

161175
[[package.metadata.android.permission]]
162176
name = "android.permission.CAMERA"
163-
164-
[dependencies.android_glue]
165-
path = "../../glue"
166177
```

cargo-apk/injected-glue/ffi.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ pub const APP_CMD_PAUSE: i32 = 13;
6262
pub const APP_CMD_STOP: i32 = 14;
6363
pub const APP_CMD_DESTROY: i32 = 15;
6464

65-
extern {
66-
pub fn app_dummy();
67-
}
68-
6965
pub const MODE_BUFFER: i32 = 3;
7066
pub const MODE_RANDOM: i32 = 1;
7167
pub const MODE_STREAMING: i32 = 2;

cargo-apk/injected-glue/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ pub fn get_app<'a>() -> &'a mut ffi::android_app {
197197
pub fn android_main2<F>(app: *mut ffi::android_app, main_function: F)
198198
where F: FnOnce() + 'static + Send
199199
{
200-
unsafe { ffi::app_dummy() };
201200
write_log("Entering android_main");
202201

203202
unsafe { ANDROID_APP = app; };

examples/advanced/Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/advanced/Cargo.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "advanced"
33
version = "0.1.0"
44
authors = ["Philip Alldredge <[email protected]"]
55
publish = false
6+
edition = "2018"
67

78
[package.metadata.android]
89
# The target Android API level.
@@ -60,6 +61,11 @@ opengles_version_minor = 2
6061
"android:screenOrientation" = "unspecified"
6162
"android:uiOptions" = "none"
6263

64+
# Adds a uses-feature element to the manifest
65+
# Supported keys: name, required, version
66+
# The glEsVersion attribute is not supported using this section.
67+
# It can be specified using the opengles_version_major and opengles_version_minor values
68+
# See https://developer.android.com/guide/topics/manifest/uses-feature-element
6369
[[package.metadata.android.feature]]
6470
name = "android.hardware.camera"
6571

@@ -68,14 +74,13 @@ name = "android.hardware.vulkan.level"
6874
version = "1"
6975
required = false
7076

71-
# Request permissions. Note that android_version 23 and higher, Android requires the application
72-
# to request permissions at runtime. There is currently no way to do this using a pure NDK based application.
77+
# Adds a uses-permission element to the manifest.
78+
# Note that android_version 23 and higher, Android requires the application to request permissions at runtime.
79+
# There is currently no way to do this using a pure NDK based application.
80+
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
7381
[[package.metadata.android.permission]]
7482
name = "android.permission.WRITE_EXTERNAL_STORAGE"
7583
maxSdkVersion = "18"
7684

7785
[[package.metadata.android.permission]]
7886
name = "android.permission.CAMERA"
79-
80-
[dependencies.android_glue]
81-
path = "../../glue"

examples/advanced/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate android_glue;
2-
31
fn main() {
4-
android_glue::write_log("main() has been called from advanced example");
5-
loop {}
2+
println!("main() has been called from advanced example");
63
}

examples/basic/Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "android_glue_example"
33
version = "0.1.0"
44
authors = ["Pierre Krieger <[email protected]>"]
5+
edition = "2018"
56

67
[package.metadata.android]
78
label = "Basic android-rs-glue example"

examples/basic/src/basic.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate android_glue;
2-
31
fn main() {
42
android_glue::write_log("main() has been called");
5-
loop {}
63
}

examples/multiple_targets/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "android_primary_bin"
33
version = "0.1.0"
44
authors = ["Philip Alldredge <[email protected]>"]
55
publish = false
6+
edition = "2018"
67

78
[dependencies.android_glue]
89
path = "../../glue"

0 commit comments

Comments
 (0)