Open kacper-cholewinski opened 1 year ago
Merry Christmas! Sorry for the late response.
Have you added everything required in Cargo.toml
as specified in this link?
Wish you same.
I think I added all things required. I got only problem with this one:
[[package.metadata.android.manifest.application.meta_data]]
I got error that I need to add some "package" property to it (when building using crossbundle).
I've tried other plugins and I get same problems.
@kacper-cholewinski can you paste error message or your Cargo.toml? Also, did you try running examples?
The error is:
error: Invalid metadata in manifest: missing field `package` for key `android.manifest`
for:
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.ads.APPLICATION_ID"
value = "ca-app-pub-3940256099942544~3347511713"
@kacper-cholewinski ... Also, did you try running examples?
That's where I've first encountered the problem.
Happy New Year btw
@kacper-cholewinski Happy New Year too.
This error looks like you forgot to specify the android manifest package in Cargo.toml:
Sorry friend, I can't reproduce this error in any example on my mac and it looks like our CI doesn't have this issue. Can you provide more info about your setup, Cargo.toml, and full error message?
Thanks for help again
I did as you suggested and now I'm in starting point:
PanicInfo { payload: Any { .. }, message: Some(called `Result::unwrap()` on an `Err` value: SingletonNotRegistered("CrossbowAdMob")), location: Location { file: "src\\__cargo_apk_mainaqyhhg.tmp", line: 11, col: 65 }, can_unwind: true }
Cargo.toml:
[package]
name = "project_name"
version = "0.1.0"
authors = REDACTED
edition = "2021"
[dependencies]
crossbow = "*"
log = "0.4"
anyhow = "1.0"
macroquad = "=0.3.7"
admob-android = "0.2.3"
crossbow-android = "0.2.3"
play-core = "0.2.3"
[patch.crates-io]
miniquad = { git = "https://github.com/not-fl3/miniquad", rev = "d67ffe6950cf73df307e2d23aaa4726f14399985" }
[package.metadata]
app_name = "Macroquad"
assets = ["assets"]
icon = "assets/icon.png"
[package.metadata.android]
app_wrapper = "quad"
release_build_targets = ["aarch64-linux-android"]
plugins_remote = ["com.crossbow.admob:admob:0.2.3", "com.crossbow.play_core:play_core:0.2.3"]
[package.metadata.android.manifest]
package = "com.crossbow.example.permissions"
[package.metadata.android.manifest.uses_sdk]
min_sdk_version = 19
target_sdk_version = 31
[[package.metadata.android.manifest.uses_permission]]
name = "android.permission.INTERNET"
[[package.metadata.android.manifest.application.meta_data]]
name = "com.google.android.gms.ads.APPLICATION_ID"
value = "ca-app-pub-3940256099942544~3347511713"
[package.metadata.apple]
release_build_targets = ["aarch64-apple-ios", "x86_64-apple-ios"]
main.rs:
use macroquad::prelude::*;
use crossbow_android::*;
#[macroquad::main("project_name")]
async fn main() {
let crossbow = CrossbowInstance::new();
// info!("initializing play core");
// let play_core: play_core::PlayCorePlugin = crossbow.get_plugin().unwrap();
info!("initializing admob");
let admob: admob_android::AdMobPlugin = crossbow.get_plugin().unwrap();
loop {
clear_background(WHITE);
draw_circle(100., 100., 100., BLUE);
next_frame().await;
}
}
I'm not experienced android developer and I know it wasn't good idea to start with developing mobile apps in rust (in current mobile ecosystem state), but I like this technology so much, that's why we are here :)
I hope it will help you figure out the problem
Hey, I succeeded in running your Cargo.toml
(also I changed the main.rs
code to the following):
use macroquad::prelude::*;
use macroquad::ui::{hash, root_ui, Skin};
use crossbow_android::*;
#[macroquad::main("project_name")]
async fn main() {
let crossbow = CrossbowInstance::new();
// info!("initializing play core");
// let play_core: play_core::PlayCorePlugin = crossbow.get_plugin().unwrap();
info!("initializing admob");
let admob: admob_android::AdMobPlugin = crossbow.get_plugin().unwrap();
let skin = get_skin();
let window_skin = skin.clone();
loop {
clear_background(WHITE);
root_ui().push_skin(&window_skin);
root_ui().window(hash!(), vec2(0.0, 50.0), vec2(1000.0, 1000.0), |ui| {
if ui.button(vec2(-15.0, 250.0), "Show ad") {
if !admob.is_initialized().unwrap() {
println!("Calling AdMob::initialize()");
admob.initialize(true, "G", false, true).unwrap();
}
if admob.is_initialized().unwrap() && !admob.is_interstitial_loaded().unwrap() {
println!("Calling load_interstitial()");
admob.load_interstitial("ca-app-pub-3940256099942544/1033173712").unwrap();
}
if admob.is_interstitial_loaded().unwrap() {
println!("Calling show_interstitial()");
admob.show_interstitial().unwrap();
}
}
});
root_ui().pop_skin();
// draw_circle(100., 100., 100., BLUE);
next_frame().await;
}
}
fn get_skin() -> Skin {
let label_style = root_ui()
.style_builder()
.text_color(Color::from_rgba(180, 180, 120, 255))
.font_size(30)
.build();
let window_style = root_ui()
.style_builder()
.background_margin(RectOffset::new(20.0, 20.0, 10.0, 10.0))
.margin(RectOffset::new(-20.0, -30.0, 0.0, 0.0))
.build();
let button_style = root_ui()
.style_builder()
.background_margin(RectOffset::new(37.0, 37.0, 5.0, 5.0))
.margin(RectOffset::new(10.0, 10.0, 0.0, 0.0))
.text_color(Color::from_rgba(180, 180, 100, 255))
.font_size(40)
.build();
let editbox_style = root_ui()
.style_builder()
.background_margin(RectOffset::new(0., 0., 0., 0.))
.text_color(Color::from_rgba(120, 120, 120, 255))
.color_selected(Color::from_rgba(190, 190, 190, 255))
.font_size(50)
.build();
Skin {
editbox_style,
window_style,
button_style,
label_style,
..root_ui().default_skin()
}
}
So the result is the following:
@kacper-cholewinski Can you try running this command: crossbundle run android --log
? The --release
flag probably has some issues.
So, I copied your code and still have same issue.
I think it could be important to add, that im using -s=native-apk
flag, cause without it I got some error during daemon initialization (with or without plugins):
EDIT: Also, it could be worth mentioning, that I'm testing on physical device (Xiaomi Redmi 9) using adb
@kacper-cholewinski Look, strategy native-apk
builds it without gradle. It will not add plugins. Can you try build with command I mentioned and paste error log?
I pasted screenshot of error above
Looks like something is wrong with generated Gradle project. It's very hard to understand what the problem is from this error message as we with @Heezay don't have this problem... I wonder, perhaps you can try to upload somewhere generated Gradle project so that I will take a look.
I'm not sure if I know what you mean, but: https://github.com/kacper-cholewinski/crossbow-plugins There is my whole workspace with target folder and Cargo.lock included, I hope it would help.
Crossbow version
0.2.3
What you did
Code:
What went wrong
I get black screen and error: Singleton with
CrossbowAdMob
name not found or haven't registered (adb logcat)Thanks for all your help