我正在原生Android中进行Unity Ads集成。但我面临以下问题。
java.lang.NoClassDefFoundError: com.unity3d.ads.android.R$layout
at com.unity3d.ads.android.video.UnityAdsVideoPlayView.e(UnityAdsVideoPlayView.java:225)
at com.unity3d.ads.android.video.UnityAdsVideoPlayView.<init>(UnityAdsVideoPlayView.java:62)
at com.unity3d.ads.android.view.UnityAdsMainView.setViewState(UnityAdsMainView.java:76)
at com.unity3d.ads.android.view.b.run(UnityAdsFullscreenActivity.java:593)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5099)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题。我在布局中有此资源文件,然后我也遇到了此错误。
这是我的奖励视频脚本。它连接到一个UI按钮。
using UnityEngine;\nusing UnityEngine.UI;\nusing UnityEngine.Advertisements;\nusing UnityEngine.SceneManagement;\n\n[RequireComponent(typeof(Button))]\npublic class RewardedAdsButton : MonoBehaviour, IUnityAdsListener\n{\n\n#if UNITY_IOS\n private string gameId = "1234567";\n#elif UNITY_ANDROID\n private string gameId = "7654321";\n#endif\n\n Button myButton;\n public string myPlacementId = "rewardedVideo";\n\n void Start()\n {\n myButton = GetComponent<Button>();\n\n // Set interactivity to be dependent on the Placement\xe2\x80\x99s status:\n myButton.interactable = Advertisement.IsReady(myPlacementId);\n\n // Map the ShowRewardedVideo function to the button\xe2\x80\x99s click listener:\n if (myButton) myButton.onClick.AddListener(ShowRewardedVideo);\n\n // Initialize the Ads listener and service:\n Advertisement.AddListener(this);\n Advertisement.Initialize(gameId, true);\n }\n\n // Implement a function …Run Code Online (Sandbox Code Playgroud)