I am trying to implement ads in my libgdx game. I am following this tutorial: https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx
The problem is with these lines.
AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxx");
adView.loadAd(new AdRequest());
I get the error, "The constructor AdView(MainActivity, AdSize, String) is undefined".
Why? I am importing "com.google.android.gms.ads.AdView";
The tutorial you followed seems outdated, It is based on AdMob 4.0.4, whereas I guess you are using the latest version (4.1).
Fortunately there is a migration guide. You have to update your code like this :
AdView adView = new AdView(this);
adView.setAdUnitId("xxxxxxxx");
adView.setAdSize(AdSize.BANNER);
Hope this helps.
Related
This article says, ProgressTimer preserved it's behavior while migration to Cocos Creator:
http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/getting-started/cocos2d-x-guide/2
So, I tried to create ProgressTimer from code with both:
var obj1 = new cc.ProgressTimer(sprite); // -> cc.ProgressTimer is not a constructor
and
var obj2 = cc.ProgressTimer.create(sprite); // -> Cannot read property 'create' of undefined
code lines and as you see nothing is working for me.
I'm using Cocos Creator 1.4.
I can't even find CCProgressTimer.js inside CocosCreator directory.
Also, I can't find CCClippingNode.js(which is also listed in preserved nodes list on Cocos Creator docs). But there is still CCSprite.js file presented. What am I missed up?
You can use the Progress Bar and do the timer yourself. Also you should read the API for the version of Cocos Creator that you are using. Many things change from version to version.
http://www.cocos2d-x.org/docs/api-ref/creator/v1.5/classes/ProgressBar.html
I started developing my game few years ago, with big pauses. There was no gradle back then, just simple java installation app. How can I find what is the version of LibGDX used?
Here you go:
Gdx.app.log("Gdx version", com.badlogic.gdx.Version.VERSION);
The answer of Xoppa is correct but I find it a very uncomfortable way of checking versions. It would be nice if the LibGDX setup tool and the big website download button showed the version number since currently (as far as I am aware of) the only way to know the version is to create a project first and I find that rather obscure.
A way to know without executing any code is to check the build.gradle file which "should" display the correct version number at line gdxVersion = 'x.x.x'.
In any I.D.E., e.g. IntelliJ, AndroidStudio etc., create a temporary class to run System.out.printf()
public class printGdxVersion{
public static void main(String[] args) {
System.out.printf(com.badlogic.gdx.Version.VERSION);
}
}
You can also find it in the project build.gradle file under:
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "BibleQuiz"
gdxVersion = '1.9.12'
roboVMVersion = '2.3.11'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.3'
aiVersion = '1.8.2'
}
I have a problem integrating MonoGame into an existing WindowsPhone8.0 project.
Everything seems to work fine, but when is start the app it's crashing with NullPointerException in MonoGame Framework.
StackTrace:
at MonoGame.Framework.WindowsPhone.WindowsPhoneGameWindow..ctor(Game game)
at MonoGame.Framework.WindowsPhone.WindowsPhoneGamePlatform..ctor(Game game)
at Microsoft.Xna.Framework.GamePlatform.PlatformCreate(Game game)
at Microsoft.Xna.Framework.Game..ctor()
at myApp.Game1..ctor()
at myApp.myPage..ctor()
EDIT:
I have also tried that: link
Based on the stack trace your myPage constructor goes somewhat like this:
_game = new Game1();
The Windows Phone project template, however, does it this way:
_game = XamlGame<Game1>.Create("", this);
The latter version does lots of initialization, for example stores a reference to the XAML page for framework use. The first version crashes because the said initialization is not done, and tries to access null page.
My app runs in WPF and Android (Windows Phone later) with mvvmcross as framework. I implemented localization with JsonLocalisation like the Babel (N21) example and it is working fine in Android. But whatever I try in WPF I get this message;
mvx:Warning: 0,22 Language file could not be loaded for Danish.SettingsViewModel -
FileNotFoundException: Unable to find resource file MyAppResources/Text/Danish/SettingsViewModel.json
at Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxContentJsonDictionaryTextProvider.
LoadJsonFromResource(String namespaceKey, String typeKey, String resourcePath) at >Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxTextProviderBuilder.LoadResources(String >whichLocalisationFolder)"
Stuart says in his video tutorial that the json translation files must be included as "Content" and not copied to the output folder - like;
But looking at the compiled executable with "dotPeek" doesn't reveal the files.
Am I missing something obvious? Any hints would be highly appreciated. Even confirmation from somebody who has JsonLocalisation working in WPF would be nice.
EDIT:
Well, I tried this code in my WPF mainWindow. I understand this call is used internally in MvxWPFResourceLoader.
public MainWindow()
{
....
//This return null without exceptions.
var t = Application.GetResourceStream(new Uri("MyAppResources/Text/Danish/SettingsViewModel.json", UriKind.Relative));
//This throwns an IOException; Cannot locate resource 'thisdoesnotexist/text/danish/settingsviewmodel.json'.
var y = Application.GetResourceStream(new Uri("ThisDoesNotExist/Text/Danish/SettingsViewModel.json", UriKind.Relative));
}
It seems when the path if wrong an exception is thrown. When it is correct it just returns null!!?! I am a bit puzzled, any ideas?
Best regards
Thank you for such fast answer (and for mvvmcross!).
The link you provided is to a Babel solution with a WPF sample - exactly what I needed. I mistakenly used the one from N21 without WPF sample :-)
Anyway, when looking at the sample I noticed that the json files must be included as 'Resource' and not 'Content'. That made all the difference - hurray!
Best regards
I have no idea why i am getting this error can somebody please tell me.. what causes this error and how to fix it...
It sounds like you're using new SharedObject(), but Shared Objects are a bit different from normal. Instead of trying to create a new instance yourself, you should be using SharedObject.getLocal like this:
private var mySo:SharedObject = SharedObject.getLocal("application-name");
But obviously change "application-name" to be something specific to your project.
There is a more detailed example in the documentation here: Shared Object Examples