In the onCreate() method of the activity I want the interstitial to appear in,
I have the following code:
MMAdView interAdView = new MMAdView(this, MY_APP_ID, MMAdView.FULLSCREEN_AD_LAUNCH, true, null);
interAdView.fetch();
interAdView.setListener(new BasicMMAdListener()
{
#Override
public void MMAdCachingCompleted(MMAdView adview, boolean success)
{
if(success)
adview.display();
}
});
The code compiles without error, but at runtime I get the following Log output
which indicates an error at the first line of my code snippet, i.e. the one
starting: MMAdView interAdView = new MMAdView(this, ...
Could not find class 'com.millennialmedia.android.MMAdView', referenced from method com.mycompany.mygame.myactivity.onCreate
I am puzzled because I thought that if there was somehow a missing
class then the app should not compile.
Thanks to Vinay's comment, it forced me to investigate another problem I'd been having first.
My problem disappeared when I resolve an earlier problem covered on SO here.
Related
I just upgraded to Bumblebee (2021.1.1). Now this line of code:
Navigation.findNavController(v).navigate(R.id.TakeATourActivity, null, null, new DynamicExtras(installMonitor));
shows as an error in the editor (it hasn't been touched in a while). I get the red squiggle under the new DynamicExtras(installMonitor) portion of the code. The error message says:
'navigate(int, android.os.Bundle, androidx.navigation.NavOptions, androidx.navigation.Navigator.Extras)' in 'androidx.navigation.NavController' cannot be applied to '(int, null, null, androidx.navigation.dynamicfeatures.DynamicExtras)'
But this doesn't make sense to me. The signature I'm using is:
public void navigate(#IdRes int resId,
#Nullable android.os.Bundle args,
#Nullable androidx.navigation.NavOptions navOptions,
#Nullable androidx.navigation.Navigator.Extras navigatorExtras)
And the DynamicExtras class does in fact implement Navigator.Exras, so...what's going on? Since it completes a full rebuild with no errors (although the squiggly line is still there), I'm assuming this is some sort of lint problem?
I just suspect that this is a lint issue (since full build completes successfully), and ended up refactoring this code anyway to use on-demand download of the feature module instead of Dynamic download.
I am trying to set up gdx-pay in my game. I have followed the official readme (https://github.com/libgdx/gdx-pay/), but can't seem to instantiate the PurchaseManager in my AndroidLauncher.
I have set up a class that handles PurchaseManager installation, but every time I try to instantiate it in the AndroidLauncher I get this error:
"java.lang.RuntimeException: Unable to start activity ComponentInfo{appPackage.AndroidLauncher}: java.lang.IllegalArgumentException: Support for pending purchases must be enabled. Enable this by calling 'enablePendingPurchases()' on BillingClientBuilder."
The readme says to add this to the AndroidLauncher onCreate
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
The problem is that I have to add this
ProjectName.purchaseManager = new PurchaseManagerGoogleBilling(this);
This give me an error saying that I have to make purchaseManager static in my ProjectName class
When I do this, I get the RuntimeException mentioned above.
The sample gdx-pay project instantiates PurchaseManager with this code
public class AndroidLauncher extends GenericAndroidLauncher {
#Override
protected void initFlavor(GdxPayApp game) {
super.initFlavor(game);
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
}
}
When I try this, #Override is invalid and initFlavor does not exist. I tried looking for initFlavor in the gdx-pay files, but had no luck finding anything...
Thanks for taking the time to help
Well it turns out that the following line in my android gradle was the issue
implementation 'com.android.billingclient:billing:2.0.1'
Gdx-pay takes care of this automatically and uses client 1.1
Setting the billingclient to 2.0.1 was the problem. I was able to fix it by deleting that line. Big thanks to the libGdx discord guys!
Suppose I have this piece of code:
public class Class1 extends Activity
{
private int [] array;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
someFunction(array.length); <--- NullPointerException
}
}
Normally the LogCat in eclipse tells me what the exception is, and where is the line that is causing trouble, but for an unknown reason, it does not anymore. Instead, it just throw the following error :
12-30 22:27:06.650: E/Trace(28894): error opening trace file: No such file or directory (2)
12-30 22:27:06.670: W/dalvikvm(28894): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
How can I solve this? I´ve seen many posts speaking of this problem, but I haven´t been able to solve the issue. Thanx.
I found that the only way to solve the issue, was shutting down eclipse and starting again. I dont know why this happens, but restarting fixed it.
I am trying to launch a new intent from my Activity, but I get a NoClassDefFoundError. The exception occurs resolving MyClassB.class. Oddly I can resolve other classes, and the error only occurs in android versions 2.2 and 2.3, it works fine in 4.0+.
Both the class that causes the error and the other classes that resolve successfully are in the same package as the Activity where the code is executing. Basically, the below code gives the below error on 2.2/2.3, but works fine on 4.0+. I have also tried using the full package name like: com.me.MyClassB.class, but get the same error.
I realized this question is pretty vague, but am thoroughly confused and hoping that somebody might be able to help.
package com.me;
public class MyActivity extends Activity
{
protected onCreate(Bundle bundle)
{
super.onCreat(bundle);
Class a = MyClassA.class;
Class b = MyClassB.class;
}
}
01-17 10:37:36.473: E/AndroidRuntime(1976): java.lang.NoClassDefFoundError: com.me.MyClassB
I'm not sure if this is the problem but in your onCreate method you need to add super.onCreate(bundle) at the beginning e.g.
protected onCreate(Bundle bundle)
{
super.onCreate(bundle);
Class a = MyClassA.class;
Class b = MyClassB.class;
}
This was caused because MyClassB.class implements ActionBar.OnNavigationListener. It seems if classes contain certain code for a higher api level, they don't get setup properly at runtime, resulting in these sorts of errors. I expecteded MyClassB.class to crash on 2.3, but the NoClassDefFoundError was particularly mystifying.
In some case, when accessing an activity field from an anonymous class, I get NoSuchFieldError at runtime: java.lang.NoSuchFieldError: MyActivity.myField
EDIT: I'm now sure that it's an Android issue, because everything compiles correctly but resolved incorrectly at runtime. When changing to MyActivity.this.myField instead of plain myField, everything works perfect.
BTW, I rechecked and I don't have any other myField anywhere else, Also, when opening declaration in Eclipse, it goes to the intended field (myField).
The only problem is that I couldn't reproduce this in a sample project. I'm left only to state that it's a specific problem in my project, but I'm reluctant doing so and I can't publish this project.
I'll keep this open in case someone stumbles upon something similar.
Here's the code that I can publish that crashes my project but not the sample one:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new Runnable() {
#Override
public void run() {
Toast.makeText(MyActivity.this, myField.getName(), Toast.LENGTH_SHORT).show();
}
}.run();
}
It seems that accessing the field with the class' prefix solves it: MyActivity.this.myField
Strange. I guess it's something with Android's field resolution in runtime.