• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - ROBOVM + robopods + admob ios 绑定(bind)

[复制链接]
菜鸟教程小白 发表于 2022-12-13 17:00:16 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我尝试使用 this 绑定(bind)我的项目但是我没有实现,所以我收到了类似的错误 noClassDefFoundFor NSObject

我也尝试添加旧版本 即this但在这里我无法将 admob 模块链接到我的 ios 模块错误,在这种情况下我得到的是: 未找到“默认”的配置

我正在使用最新版本的 LibGDX。

日志片段:

ava.lang.NoClassDefFoundError: org/robovm/apple/foundation/NSObject$Handle
at org.robovm.pods.google.mobileads.GADRequest.<init>(GADRequest.java)
at com.blurpixel.arcpop.ViewController.createAndLoadBanner(ViewController.java)
at com.blurpixel.arcpop.ViewController.intializeAds(ViewController.java)
at com.blurpixel.arcpop.ViewController.showAds(ViewController.java)
at com.blurpixel.arcpop.Menu.show(Menu.java)
at com.badlogic.gdx.Game.setScreen(Game.java)
at com.blurpixel.arcpop.GameClass.create(GameClass.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics.draw(IOSGraphics.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.draw(IOSGraphics.java)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.$cb$drawRect$(IOSGraphics.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at com.blurpixel.arcpop.IOSLauncher.main(IOSLauncher.java)

我在我的代码中所做的是:

 adView = new GADBannerView(GADAdSize.SmartBannerPortrait());
    adView.setAdUnitID("xxxxxxxxxxxxxxx");
    adView.setRootViewController(UIApplication.getSharedApplication().getKeyWindow().getRootViewController());
    UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView().addSubview(adView);

    GADRequest request = new GADRequest();//this line is creating this error if i am commenting this line + the adview.loadAd line i am getting my game running without ads.
   request.setTestDevices(Arrays.asList(GADRequest.getSimulatorID()));
    adView.setDelegate(new GADBannerViewDelegateAdapter() {
        @Override
        public void didReceiveAd(GADBannerView view) {
            super.didReceiveAd(view);
        }
        @Override
        public void didFailToReceiveAd(GADBannerView view, GADRequestError error) {
            super.didFailToReceiveAd(view, error);
            System.out.println("Failed to recieve ");
        }
    });
    adView.loadRequest(request);

Gradle 文件:

ios 分级:

    sourceSets.main.java.srcDirs = ["src/"]
 sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
ext {
    mainClassName = "com.blurpixel.arcpop.IOSLauncher"
}
launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build
eclipse.project {
    name = appName + "-ios"
    natures 'org.robovm.eclipse.RoboVMNature' 
}  
dependencies {

    compile "org.robovm:robopods-google-mobile-ads-ios:1.13.1-SNAPSHOT"
    compile "org.robovm:robopods-google-apis-ios:1.13.1-SNAPSHOT"
}

build.gradle:

    buildscript {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }


    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0-SNAPSHOT'
    }
}
allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.2'
    ext {
        appName = "ArcPOP"
        gdxVersion = '1.9.2'
        roboVMVersion = '1.14.0'
        robopodsVersion = '1.13.1'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
        admobVersion = '9.0.1'
    }

    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}
project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjglgdxVersion"
        compile "com.badlogicgames.gdx:gdx-platformgdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-toolsgdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype-platformgdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platformgdxVersion:natives-desktop"
    }
}
project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")

        compile "com.badlogicgames.gdx:gdx-backend-androidgdxVersion"
        natives "com.badlogicgames.gdx:gdx-platformgdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platformgdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platformgdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platformgdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"

        compile 'com.google.android.gms:play-services-ads:9.0.1'
        compile 'com.facebook.android:facebook-android-sdk:4.1.0'

    }
}
project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"


    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:$roboVMVersion"
        compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "org.robovm:robopods-google-mobile-ads-ios:$robopodsVersion-SNAPSHOT"
        compile "org.robovm:robopods-google-apis-ios:$robopodsVersion-SNAPSHOT"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
    }
}
project(":html") {
    apply plugin: "gwt"
    apply plugin: "war"
    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
        compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
        compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
    }
}
project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    }
}
tasks.eclipse.doLast {
    delete ".project"
}
dependencies {
}

请提前帮助和感谢。



Best Answer-推荐答案


问题出在您的 gradle 文件中。首先,您将 mobidevelop 插件与官方 robovm 一起使用。这可能会带来问题。

那么您将在 2 个地方添加依赖项。这不应该做任何坏事,但它不是必需的,如果您更改其中一个可能会导致问题。

应用以下更改,重建 gradle(不要忘记 --refresh-dependencies)并重建您的项目。如果仍然失败,请再次清除缓存。

改变:

classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0-SNAPSHOT'      

classpath 'org.robovm:robovm-gradle-plugin:1.14.0'

robopodsVersion = '1.13.1'

robopodsVersion = '1.14.0'

可能还需要改变:

gdxVersion = '1.9.2'

gdxVersion = '1.9.0'

您可能还需要从 robopod 版本中删除“-SNAPSHOT”。不是 100% 确定它们存在(如果你想要这些)

删除:

dependencies {

    compile "org.robovm:robopods-google-mobile-ads-ios:1.13.1-SNAPSHOT"
    compile "org.robovm:robopods-google-apis-ios:1.13.1-SNAPSHOT"
}

来自 ios build.gradle(这些区域已经在你的 main build.gradle 中定义)

关于ios - ROBOVM + robopods + admob ios 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37917578/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap