appodeal / react-native-appodeal

Official React Native package that adds Appodeal SDK support to your react-native application.
https://appodeal.com
59 stars 37 forks source link

Android RNAppodeal.requestAndroidMPermissions got 1 arguments, expected 0 #65

Closed SMJ93 closed 3 years ago

SMJ93 commented 3 years ago

Hi, this looks like a great alternative to AdMob, but I am having a lot of difficulty getting it working on Android.

I've followed the instructions in the Read me and installed: "react-native-appodeal": "2.7.6"

On Android I get the following when initialising:

com.facebook.react.bridge.NativeArgumentsParseException: RNAppodeal.requestAndroidMPermissions got 1 arguments, expected 0

Looking at requestAndroidMPermissions.ts it looks like you are parsing through a callback, but not in expecting it in the Java code?

Screenshot_1605538510

Env:

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 276.11 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.9.1 - ~/.nvm/versions/node/v12.9.1/bin/node
    Yarn: 1.22.10 - ~/Documents/projects/translation-app/node_modules/.bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.9.1/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 12.2/12B45b - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_172 - /usr/bin/javac
    Python: 2.7.15 - /usr/local/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.3 => 0.63.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
staskochkin commented 3 years ago

@SMJ93 Fix for this issue was added into react-native-appodeal@2.7.7.

SMJ93 commented 3 years ago

@staskochkin, Android now crashes with the following:

11-18 15:48:09.117 11244 11368 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/appodeal/ads/bt;
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.appodeal.ads.aq.a(Unknown Source:4)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.appodeal.ads.Appodeal.setTriggerOnLoadedOnPrecache(Unknown Source:32)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.appodeal.rnappodeal.RNAppodealModule.setOnLoadedTriggerBoth(RNAppodealModule.java:273)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:883)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:100)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:919)
11-18 15:48:09.117 11244 11368 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: com.appodeal.ads.bt
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.VMClassLoader.findLoadedClass(Native Method)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    ... 13 more
11-18 15:48:09.117 11244 11368 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/appodeal/ads/r;
11-18 15:48:09.117 11244 11368 E AndroidRuntime:    ... 13 more
staskochkin commented 3 years ago

How do you call setOnLoadedTriggerBoth? It takes the boolean value as an argument.

Appodeal.setOnLoadedTriggerBoth(false);
SMJ93 commented 3 years ago

@staskochkin using Appodeal.setOnLoadedTriggerBoth(true).

It works fine on iOS, but Android crashes.

Here is all of my initialising code:

export function initialiseAppodeal() {
  // Generic settings

  // Set ad auto caching enabled or disabled
  // By default autocache is enabled for all ad types
  // Call this method before or after initilisation
  Appodeal.setAutoCache(AppodealAdType.BANNER, true)

  // Set testing mode
  // Call this method before initilisation
  Appodeal.setTesting(isDev)

  // Set Appodeal SDK logging level
  // Call this method before initilisation
  const logLevel = isDev ? AppodealLogLevel.DEBUG : AppodealLogLevel.NONE
  Appodeal.setLogLevel(logLevel)

  // Enable or disable child direct threatment
  // Call this method before initilisation
  Appodeal.setChildDirectedTreatment(false)

  // Disable network:
  // Call this method before initilisation
  // Appodeal.disableNetwork("some_network")

  // Disable network for specific ad type:
  // Call this method before initilisation
  // Appodeal.disableNetwork("some_network ", AppodealAdType.INTERSTITIAL)

  // Enable or disable triggering show for precache ads
  // Call this method before or after initilisation
  Appodeal.setOnLoadedTriggerBoth(true)

  // Disable location permission
  // Call this method before initilisation
  Appodeal.disableLocationPermissionCheck()

  // Banner specific settings
  // Enable or disable tablet banners.
  // Call this method before of after initilisation
  Appodeal.setTabletBanners(isLargeDevice)

  // Enable or disable smart banners.
  // iOS smart banners are supported only
  // for applications where autoration is disabled
  // Call this method before of after initilisation
  Appodeal.setSmartBanners(false)

  // Enable or disable banner refresh animation
  // Call this method before of after initilisation
  Appodeal.setBannerAnimation(true)

  // Enable or disable banner background
  // Call this method before of after initilisation
  Appodeal.setBannerBackground(false)

  // Android specific settings
  // Mute calls if calls muted on Android
  // Call this method before initilisation
  if (!isIOS) {
    Appodeal.muteVideosIfCallsMuted(true)
    // Disable write external permission warning on app start if its missing
    // Call this method before initilisation

    Appodeal.disableWriteExternalStoragePermissionCheck()
    // Request Android M permissions on app start
    // Call this method before initilisation
    // Appodeal.requestAndroidMPermissions()
  }

// Initialise
  const appodealKey = getAppodealKey()
  const adTypes =
    AppodealAdType.INTERSTITIAL |
    AppodealAdType.REWARDED_VIDEO |
    AppodealAdType.BANNER
  const consent = true
  Appodeal.initialize(appodealKey, adTypes, consent)
}
SMJ93 commented 3 years ago

Hi @staskochkin, setting Appodeal.setOnLoadedTriggerBoth(false) results in Android building 🎉

I am still having problems with Android though. The test Advert doesn't loaded and onAdFailedToLoad doesn't fire. It is working as expected on iOS.