首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ROBOVM + robopods + admob ios绑定

ROBOVM + robopods + admob ios绑定
EN

Stack Overflow用户
提问于 2016-06-20 08:18:54
回答 1查看 1.1K关注 0票数 2

我试图用绑定我的项目,但是我没有成功,所以我得到了像noClassDefFoundFor NSObject这样的错误。

我还尝试添加旧版本的,但在这里我无法将admob模块链接到我的ios模块错误,在本例中我得到的是:没有为“默认”找到配置

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

日志片段:

代码语言:javascript
复制
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)

我在代码中所做的是:

代码语言:javascript
复制
 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);

分级档案:

ios级:

代码语言:javascript
复制
    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:

代码语言:javascript
复制
    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-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
    }
}
project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")

        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion: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 {
}

请提前帮助和感谢。

EN

回答 1

Stack Overflow用户

发布于 2016-06-22 12:34:02

问题在于你的分级文件。首先,您使用的是带有官方机器人的mobidevelop插件。这可能会带来问题。

然后在两个地方添加依赖项。这不应该做任何坏事,但它是不需要的,并可能导致问题,如果你改变其中之一。

应用以下更改,重新构建gradle (不要忘记--刷新-依赖关系)并重建您的项目。如果仍然失败,请清除缓存。

改变:

代码语言:javascript
复制
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0-SNAPSHOT'      

代码语言:javascript
复制
classpath 'org.robovm:robovm-gradle-plugin:1.14.0'

代码语言:javascript
复制
robopodsVersion = '1.13.1'

代码语言:javascript
复制
robopodsVersion = '1.14.0'

还可能需要改变:

代码语言:javascript
复制
gdxVersion = '1.9.2'

代码语言:javascript
复制
gdxVersion = '1.9.0'

您还可能需要从robopod版本中删除"-SNAPSHOT“。不能百分之百地确定它们的存在(如果你想要的话)

移除:

代码语言:javascript
复制
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 (这些区域已经在您的主build.gradle中定义)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37917578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档