question

artgallery42 avatar image
artgallery42 asked

Ads not showing in test mode but where ads should be showing can be clicked

Hi, Integrated ad network ok, build is clean, listener is showing that ad is loaded, using xml for ad placement with width 320dp height 50dp. The banner doesn't show, but the area where the banner should be showing is clickable and goes to Pinzon. There is a message in the error log: "com.amazon.device.ads.AdLayout failed to instantiate." and the stack trace is: java.lang.NoClassDefFoundError: Could not initialize class android.os.Environment at com.amazon.device.ads.DebugProperties.readDebugProperties(DebugProperties.java:83) at com.amazon.device.ads.InternalAdRegistration. (InternalAdRegistration.java:62) at com.amazon.device.ads.InternalAdRegistration. (InternalAdRegistration.java:58) at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:204) at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:184) at com.amazon.device.ads.AdLayout. (AdLayout.java:128) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:437) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:189) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:373) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:504) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1584) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1309) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1066) at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:686) at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360) at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:292) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:778) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3061) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1753) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:278) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450) enableTesting is set to true. using Htc one x plugged in as an emulator. used "sample-app-v1_pub-2" as an id, as well as my own. and tried Java Build Path > Order and Export > Amazon jar - both ticked and un-ticked. using amazon-ads-5.1.242.jar according to logcat, banners images are being cached ok.
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Artgallery42, Could you please execute below line of code in your emulator? String storageState = Environment.getExternalStorageState(); If it gives same or different error can you please check that you have configured SD card properly in your emulator. Also can you please try adding below permission in the manifest? Please let us know the result. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

artgallery42 avatar image
artgallery42 answered
Hi Sujoy, Thanks for the reply. I'm using my phone as an emulator, like I said in my OP, so I don't think SD card is the issue. I added the permission READ_EXTERNAL_STORAGE but I'm still getting the same stack trace as I posted above. In logcat i'm seeing ads loading successfully, images being cached correctly and amazon url's being logged, so it all looks good, except it's unable to instantiate the com.amazon.device.ads.AdLayout class. btw, I can see the ad layout in the graphical view in the layout.xml and that looks to be correct. Usually, if anything's wrong with a layout element there's an exclamation mark on the element, I think? Message was edited by: artgallery42
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

artgallery42 avatar image
artgallery42 answered
Just found that there's another stack trace, didn't notice before as it was the same message: com.amazon.device.ads.AdLayout failed to instantiate. stack trace: java.lang.NoClassDefFoundError: Could not initialize class com.amazon.device.ads.InternalAdRegistration at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:204) at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:184) at com.amazon.device.ads.AdLayout. (AdLayout.java:128) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:437) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:189) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:727) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:373) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:504) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1584) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1309) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1066) at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:686) at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360) at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:292) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:778) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3061) at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1753) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:278) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450) So I'm getting this stack trace and the original stack trace each time.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

artgallery42 avatar image
artgallery42 answered
Looks to be a similar issue reported here last Sept, with no resolution so far... http://forums.developer.amazon.com/forums/message.jspa?messageID=5438
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi, This issue reported in the other thread is already reported to concerned team here. The issue was adding AdLayout does not work in Graphical Android Eclipse Plugin. And the error is thrown by com.android.ide.eclipse.adt.internal.editors during editing the layout xml using graphical editor. There was no problem in runtime for displaying the ad. The layout could be written by hand and not by using the graphical editor. We will fix this issue in editor in future release. But you are getting java.lang.NoClassDefFoundError: Could not initialize class android.os.Environment While trying display the ad in the emulator. Right? I am trying find the root cause of this issue. You wrote you are using your HTC one device as emulator. Could you please check you app just by running in the device (not as emulator)? You can try to run our sample Ad app in to your device. Please share the result.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

artgallery42 avatar image
artgallery42 answered
Hi, Yes, as I reported above, I'm getting two different stack traces each time I run a project. This one: java.lang.NoClassDefFoundError: Could not initialize class android.os.Environment and this one: java.lang.NoClassDefFoundError: Could not initialize class com.amazon.device.ads.InternalAdRegistration which appears to be a similar issue to the one reported here: http://forums.developer.amazon.com/forums/message.jspa?messageID=5438 Maybe one causes the other? or they're separate issues? I don't know. I get these same two errors in the Amazon SimpleAdSample project too, but for some reason I am able to see the banners. It's baffling to me because I ended up just moving the code out of the sample project into my own project, yet cannot see the banners, even though the area where they should be is clickable.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Artgallery42, Amazon Mobile Ads work in Android and Kindle devices. I am trying to figure out what is different in your environment. Please ignore the second issue since it's a known issue and will be addressed in upcoming releases. The concern I can see the below error java.lang.NoClassDefFoundError: Could not initialize class android.os.Environment at com.amazon.device.ads.DebugProperties.readDebugProperties(DebugProperties.java:83) And in line 83 code we try to run below code String storageState = Environment.getExternalStorageState(); Please answer my below questions so that I can present the issue correctly to concerned team here. 1. What did you mean by "Htc one x plugged in as an emulator". I am not aware of this. Is there any guide that I can use my Android phone as emulator. I doubt we have ever tested our SDK in this environment. 2. What happens when you execute below line in your emulated phone? String storageState = Environment.getExternalStorageState(); Please log storageState by running it from a simple test app and paste the returned value here. I am sorry for taking little time to realize the issue. Thanks for your cooperation.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.