Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Android #11

Open
customautosys opened this issue Dec 30, 2021 · 4 comments
Open

Not working on Android #11

customautosys opened this issue Dec 30, 2021 · 4 comments

Comments

@customautosys
Copy link

I marked my method @async and didn't call it in a lambda or anonymous class but still got the following error:

java.lang.UnsupportedOperationException: The method "JPromise#await" should be invoked in an async method. An async method is a method annotated with @JAsync and returning the JPromise object. The method should not be a lambda method or in an anonymous class
	at io.github.vipcxj.jasync.reactive.ReactorPromise.await(ReactorPromise.java:450)

Relevant code below:

@Async
public void loadAd(){
	try{
		AdManager.instance().interstitial().await();
		...
	}catch(Exception e){
		e.printStackTrace();
	}
}

public class AdManager extends com.customautosys.tuxfight.AdManager{
	@Override
	public JPromise<Void> interstitial(){
		if(AndroidLauncher.getInstance().adView==null) return JAsync.error(new Exception("AdMob not loaded yet"));
		return Promises.from(Mono.create(monoSink->AndroidLauncher.getInstance().runOnUiThread(()->InterstitialAd.load(
			AndroidLauncher.getInstance(),
			BuildConfig.DEBUG?"ca-app-pub-...":"ca-app-pub-...",
			new AdRequest.Builder().build(),
			new InterstitialAdLoadCallback(){
				@Override
				public void onAdLoaded(@NonNull InterstitialAd interstitialAd){
					interstitialAd.show(AndroidLauncher.getInstance());
					monoSink.success();
				}

				@Override
				public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){
					monoSink.error(new Exception(loadAdError.getMessage()));
				}
			}
		))));
	}
}
@customautosys
Copy link
Author

I'm also getting this despite including jasync-core-java9:

java.lang.IllegalArgumentException: Unsupported class file major version 61

@vipcxj
Copy link
Owner

vipcxj commented Jan 1, 2022

Can you provide me an simple android project? I have not an android project to test it.
By the way, this project require jdk8. I know the latest android support java 8, but the old version not. And a valid async method must return a JPromise object. And in you case, you return void.

@jzlhll
Copy link

jzlhll commented Jan 12, 2022

android java8 is similar implements partly by google. It's not full

@customautosys
Copy link
Author

Hi, so sorry I haven't had the time recently because I managed to use ea-async instead which could work out of the box with Android.

I'll try to create a sample Android project for you when I have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants