I'm trying to incorporate Amazon's Mobile Ads but keep running into an issue where Android Studio says:
Rendering Problems
The following classes could not be instantiated:
- com.amazon.device.ads.AdLayout(Open Class, Show Exception)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE
When clicking 'Show Exception':
java.lang.NoClassDefFoundError: Could not initialize class android.os.Environment
at com.amazon.device.ads.DebugProperties.readDebugProperties(DebugProperties.java:78)
at com.amazon.device.ads.InternalAdRegistration.<init>(InternalAdRegistration.java:58)
at com.amazon.device.ads.InternalAdRegistration.<clinit>(InternalAdRegistration.java:54)
at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:203)
at com.amazon.device.ads.AdLayout.initialize(AdLayout.java:183)
at com.amazon.device.ads.AdLayout.<init>(AdLayout.java:127)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:365)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:97)
at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:148)
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.tools.idea.rendering.RenderService$3.compute(RenderService.java:542)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:535)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:939)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:535)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:577)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7$2.compute(AndroidDesignerEditorPanel.java:501)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7$2.compute(AndroidDesignerEditorPanel.java:494)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:950)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7.run(AndroidDesignerEditorPanel.java:494)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:237)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:297)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
I'm trying to follow the steps outlined on https://developer.amazon.com/public/apis/earn/mobile-ads/docs/quick-start, but they don't include them for Android Studios.
As for my project: - I have amazon-ads-5.1.153.jar in my project's libs folder, and have it added as a library.
Within the project Structure, I have the library added to my main Module, checked for Export.
Added the line to my manifest:
And within my build.gradle, I have added in:
dependencies { compile files('libs/amazon-ads-5.1.153.jar') }
And the view was copy-pasted from one of their examples:
<com.amazon.device.ads.AdLayout
android:id="@+id/adView"
android:layout_width="320dp"
android:layout_height="50dp"
Amazon:adSize="320x50"/>