diff --git a/cargo-apk/injected-glue/lib.rs b/cargo-apk/injected-glue/lib.rs index 6e7e144..388ad05 100644 --- a/cargo-apk/injected-glue/lib.rs +++ b/cargo-apk/injected-glue/lib.rs @@ -641,3 +641,22 @@ pub fn load_asset(filename: &str) -> Result, AssetError> { }; Ok(vec) } + +// Exported function which is called be Android's NativeActivity +#[no_mangle] +pub unsafe extern "C" fn ANativeActivity_onCreate( + activity: *mut c_void, + saved_state: *mut c_void, + saved_state_size: usize, +) { + native_app_glue_onCreate(activity, saved_state, saved_state_size); +} + +extern "C" { + #[allow(non_snake_case)] + fn native_app_glue_onCreate( + activity: *mut c_void, + saved_state: *mut c_void, + saved_state_size: usize, + ); +} diff --git a/cargo-apk/native_app_glue/android_native_app_glue.c b/cargo-apk/native_app_glue/android_native_app_glue.c index 7eada08..332afb2 100644 --- a/cargo-apk/native_app_glue/android_native_app_glue.c +++ b/cargo-apk/native_app_glue/android_native_app_glue.c @@ -420,8 +420,9 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) android_app_set_input((struct android_app*)activity->instance, NULL); } -JNIEXPORT -void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, +// Called by ANativeActivity_onCreate which will be exported and will call this function. +// Needed because this symbol will not be globally exported. +void native_app_glue_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) { LOGV("Creating: %p\n", activity); activity->callbacks->onDestroy = onDestroy; diff --git a/cargo-apk/src/main.rs b/cargo-apk/src/main.rs index 693986f..f322b68 100644 --- a/cargo-apk/src/main.rs +++ b/cargo-apk/src/main.rs @@ -325,7 +325,7 @@ pub fn execute_install(options: &ArgMatches, cargo_config: &CargoConfig) -> carg &workspace, &options.value_of("package").map(|s| s.to_owned()), )?; - android_config.release = options.is_present("release"); + android_config.release = !options.is_present("debug"); ops::install(&workspace, &android_config, &options)?; Ok(()) diff --git a/cargo-apk/src/ops/build/compile.rs b/cargo-apk/src/ops/build/compile.rs index 17ed599..dcb4c88 100644 --- a/cargo-apk/src/ops/build/compile.rs +++ b/cargo-apk/src/ops/build/compile.rs @@ -215,14 +215,14 @@ pub extern "C" fn android_main(app: *mut ()) {{ fs::create_dir_all(&build_path).unwrap(); // - // Change crate-type from bin to dylib + // Change crate-type from bin to cdylib // Replace output directory with the directory we created // let mut iter = new_args.iter_mut().rev().peekable(); while let Some(arg) = iter.next() { if let Some(prev_arg) = iter.peek() { if *prev_arg == "--crate-type" && arg == "bin" { - *arg = "dylib".into(); + *arg = "cdylib".into(); } else if *prev_arg == "--out-dir" { *arg = build_path.clone().into(); }