Unity Community


Page 1 of 9 123 ... LastLast
Results 1 to 20 of 171
  1. Super Moderator
    Location
    Vilnius, LT
    Posts
    662

    AdMob plugin that works in Unity 3.2

    Here is the basic AdMob plugin implementation that works with Unity 3.2

    Please give it a try and share your experience.
    Attached Files
    I know about iOS, Android, Flash and something else
    personal blog: drinkandcode.com
    twitter: iWozik


  2. Posts
    15
    Cool. I'll be trying this tonight along with the 3.2 OpenFeint Plugin.


  3. Posts
    15

    Force Close

    I imported the package and ran on my droid and got a force close. I'm not seeing anything relevant in the logs so I'm a bit lost. I'm also not sure how to implement this from the get go. I looked through all the included files and didn't see anything that points to a specific admob account. Any direction is greatly appreciated.

    Edit: I solved my issue and got this working, see my last post below.
    Last edited by christo; 02-15-2011 at 08:56 PM.


  4. Posts
    15

    Stack Trace

    OK I attached the debugger and got the stack trace:

    E/AndroidRuntime(17925): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.oyo.FanBoyLite/com.oyo.FanBoyLite.AdMobTestActivity}: java.lang.ClassNotFoundException: com.oyo.FanBoyLite.AdMobTestActivity in loader dalvik.system.PathClassLoader[/data/app/com.oyo.FanBoyLite-1.apk]
    E/AndroidRuntime(17925): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2585)
    E/AndroidRuntime(17925): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2679)
    E/AndroidRuntime(17925): at android.app.ActivityThread.access$2300(ActivityThr ead.java:125)
    E/AndroidRuntime(17925): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:2033)
    E/AndroidRuntime(17925): at android.os.Handler.dispatchMessage(Handler.java:99 )
    E/AndroidRuntime(17925): at android.os.Looper.loop(Looper.java:123)
    E/AndroidRuntime(17925): at android.app.ActivityThread.main(ActivityThread.jav a:4627)
    E/AndroidRuntime(17925): at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(17925): at java.lang.reflect.Method.invoke(Method.java:521)
    E/AndroidRuntime(17925): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:85
    E/AndroidRuntime(17925): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:616)
    E/AndroidRuntime(17925): at dalvik.system.NativeStart.main(Native Method)
    E/AndroidRuntime(17925): Caused by: java.lang.ClassNotFoundException: com.oyo.FanBoyLite.AdMobTestActivity in loader dalvik.system.PathClassLoader[/data/app/com.oyo.FanBoyLite-1.apk]
    E/AndroidRuntime(17925): at dalvik.system.PathClassLoader.findClass(PathClassL oader.java:243)
    E/AndroidRuntime(17925): at java.lang.ClassLoader.loadClass(ClassLoader.java:5 73)
    E/AndroidRuntime(17925): at java.lang.ClassLoader.loadClass(ClassLoader.java:5 32)
    E/AndroidRuntime(17925): at android.app.Instrumentation.newActivity(Instrument ation.java:1021)
    E/AndroidRuntime(17925): at android.app.ActivityThread.performLaunchActivity(A ctivityThread.java:2577)
    E/AndroidRuntime(17925): ... 11 more


    I know that class is in the plugin so I'm not sure why it can't find it.


  5. Posts
    15
    The example package works if run in its own project. I believe the problem is that my package name is com.oyo.FanBoyLite, where the example plugin uses org.example.AdMobTest . I am currently researching how to change the package name and rebuild. I'll report my results here.


  6. Posts
    15
    I tried importing the plugin into eclipse and renaming the package. Still getting the same error.


  7. Posts
    15
    Just tried adding the classes.jar and admobsdk.jar to my build path in eclipse and cleaned my project. STILL getting the classnotfound exception.

  8. Super Moderator
    Location
    Vilnius, LT
    Posts
    662
    did you try changing package org.example.AdMobTest; at AdMobTestActivity.java and package="org.example.AdMobTest" at AndroidManifest.xml to com.oyo.FanBoyLite?
    I know about iOS, Android, Flash and something else
    personal blog: drinkandcode.com
    twitter: iWozik


  9. Posts
    15
    Yes. My initial problem was in the manifest file. Now I have copied my projects manifest file and attempted to add the admob activity to it:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Company.ProductName" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="6" />
    <supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true"/>

    <application
    android:icon="@drawable/app_icon"
    android:label="@string/app_name">

    <activity android:name="com.unity3d.player.UnityPlayerActivi ty"
    android:label="@string/app_name"
    android:configChanges="keyboardHidden|orientation" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    <activity android:name=".AdMobTestActivity"
    android:label="admob">
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:screenOrientation="landscape"/>
    </activity>

    <!-- The application's publisher ID assigned by AdMob -->
    <meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />


    <!-- AdMobActivity definition -->
    <activity android:name="com.admob.android.ads.AdMobActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:configChanges="orientation|keyboard|keyboa rdHidden" />

    <!-- Track Market installs -->
    <receiver android:name="com.admob.android.ads.analytics.Inst allReceiver" android:exported="true">
    <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER " />
    </intent-filter>
    </receiver>
    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_ST ATE" />
    </manifest>


    The game runs without crashing now. But I don't see anything indicating that the admob activity is running. There are no ads and nothing in logcat that indicates that it is running. Obviously I did replace the publisher ID with my publisher ID.


  10. Posts
    15

    Got it Working!

    OK, after changing all occurrences of the package name to my package name, I was still getting the class not found exception...BUT...at some point I had changed the package name in Player Settings to try test some things out. When I changed it back I changed it to com.oyo.FanBoyLIte...note the capital "i". Changing this to com.oyo.FanBoyLite fixed! I've never been so excited to see an ad in my life haha. I'll post my final manifest file below just for clarification.

    THANKS!

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.oyo.FanBoyLite" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="6" />
    <supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true"/>

    <application
    android:icon="@drawable/app_icon"
    android:label="@string/app_name">

    <activity android:name=".AdMobTestActivity"
    android:label="@string/app_name"
    android:configChanges="keyboardHidden|orientation" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    <!-- The application's publisher ID assigned by AdMob -->
    <meta-data android:value="put your ID here" android:name="ADMOB_PUBLISHER_ID" />


    <!-- AdMobActivity definition -->
    <activity android:name="com.admob.android.ads.AdMobActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:configChanges="orientation|keyboard|keyboa rdHidden" />

    <!-- Track Market installs -->
    <receiver android:name="com.admob.android.ads.analytics.Inst allReceiver" android:exported="true">
    <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER " />
    </intent-filter>
    </receiver>
    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_ST ATE" />
    </manifest>


  11. Posts
    307
    Has anyone integrated this with OpenFeint at the same time?


  12. Posts
    15
    I know its possible. I think you have to combine this with the OpenFeintFacade example. In the OpenFeintFacade example, activities are called from C#, so theoretically you could extend the main activity for admob, then call openfeint activities using the Facade.

    Look at my manifest.xml in the post above, I'm already extending the main activity to use the admobtest activity, so you could paste the contents of the openfeintfacade manifest below that and it should work. Hopefully I'll be able to try it out tonight and I'll let you know how it goes.


  13. Posts
    307
    That would be great, thank you


  14. Posts
    15
    BTW add this line to your admobtestactivity.java in org/example/admobtest to place your ads at the bottom of the screen:

    layout.setGravity(android.view.Gravity.BOTTOM);

    you'll need to cd to your Plugins/Android directory and run "ant create-jar" to rebuild the plugin. If the build is successful you can hit build and run in unity and it should run on your device.


  15. Posts
    15
    OK It worked.
    First copy your project directory in case something bad happens (I had an unrecoverable crash when trying to import assets)

    next open your project with admob installed.
    drag/drop all the files from the openfeintfacade EXCEPT for androidmanifest.xml into your projects plugin dir
    copy the OF activities into your existing androidmanifest.xml
    Build>Run.

    I logged into OF successfully and Admob was called, though the ad failed. But that means that the class got called so thats really all that matters.

    Heres what your android manifest.xml should look like:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.oyo.FanBoyLite" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
    <uses-sdk android:minSdkVersion="6" />
    <supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:anyDensity="true"/>

    <application
    android:icon="@drawable/icon"
    android:label="@string/app_name">

    <activity android:name=".AdMobTestActivity"
    android:label="@string/app_name"
    android:configChanges="keyboardHidden|orientation"
    android:gravity="bottom">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    <!-- The application's publisher ID assigned by AdMob -->
    <meta-data android:value="a14d56bcab13292" android:name="ADMOB_PUBLISHER_ID" />


    <!-- AdMobActivity definition -->
    <activity android:name="com.admob.android.ads.AdMobActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:configChanges="orientation|keyboard|keyboa rdHidden" />

    <!-- Track Market installs -->
    <receiver android:name="com.admob.android.ads.analytics.Inst allReceiver" android:exported="true">
    <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER " />
    </intent-filter>
    </receiver>

    <activity android:name="com.openfeint.internal.ui.IntroFlow"
    android:label="IntroFlow"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:screenOrientation="portrait"/>

    <activity android:name="com.openfeint.api.ui.Dashboard"
    android:label="Dashboard"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:screenOrientation="portrait"/>

    <activity android:name="com.openfeint.internal.ui.Settings"
    android:label="Settings"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar"
    android:screenOrientation="portrait"/>
    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_ST ATE" />
    </manifest>


  16. Posts
    307
    Wow, thank you very much buddy, you just made my day

    Regards


  17. Posts
    15
    One note here:

    I just tried to change my admobtestactivity.jar and ran ant create-jar. When I tried to build and run i got an error saying "building dex failed". I couldn't figure it out so what I did was go back to my project that just had admob (no openfeint) and made the change there and ran ant create-jar, then integrated openfeint again. This worked perfectly.

    I realize that this isn't an ideal fix if you are going to change your admobtestactivity.jar a lot, but I don't plan to.


  18. Posts
    1
    I am going through all the steps I found here. I changed the package in the AdMobTestActivity.java file and I changed the package in AndroidManifest.xml,

    Do I have to change the jar file to read my-package.jar instead of org.example.AdMobTest.jar, I changed that to be my-package.jar and I changed the structure of the filders in the bin/classes to com/my-company/my-productName

    and also change the folder structure in src to com/my-company/my-productName so the AdMobTestActivity.java file is in that structure.

    I can't get it to work, my device always force closes, and I check the log cat and its still giving me that ClassNotFoundException in the logcat.

    Anything else I can check? Or is there any other place I have to change names of folders, files, or instances in files??


  19. Posts
    121
    @Christo : Can you make a video tutorial? I think many of us may need that

    Thanks


  20. Posts
    33
    E/AndroidRuntime( 3706): FATAL EXCEPTION: main
    E/AndroidRuntime( 3706): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.FilmProfit.STAB/com.FilmProfit.STAB.AdMobTestActivity}: java.lang.ClassNotFoundException:com.FilmProfit.ST AB.AdMobTestActivity i
    n loader dalvik.system.PathClassLoader[/mnt/asec/com.FilmProfit.STAB-1/pkg.ap
    k]
    Edit #3
    Ok.
    Reason the package by itself doesnt display any ads is it looks like the manifest needs this line:
    <uses-permission android:name="android.permission.ACCESS_NETWORK_ST ATE" />
    Tyvm christo.

    What I've done to get it working in my own project, is first add it to my project.
    Let it build and crash on the android.
    Went to my project's temp folder, copied out the Staging folder.
    Moved this to another area completely.
    Made a new project in Eclipse based on the Relocated Staging folder.
    Fixed all of the org.exmaple.AdMobTest calls.
    Fixed the references to Jar library files (Was pointing to an utterly different folder for Unity than what I have on x64 windows)
    >C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\androidpla yer\bin
    Made sure to include the admob-sdk-android.jar file as a library.
    NOTE:
    This looks to be an older admob library, which I am guessing is where the edits were done Wozik, as the AdMobTestActivity class is in there along with a bunch of other things, that is not in the current admob library, GoogleAdMobAdsSDK-4.0.2.jar
    So good thing that was put together.

    There were a few minor fixes here and there with things to get it to generate AdMobTestActivity correctly. But its done and working now.

    I will now be attempting to convert this back to plug-in status for my project.

    Thanks.

    Edit #4
    Well, Day 3. I dont even know what I did, I literally changed nothing, even restorted the AdMobTestActivity project in Eclipse that was working. Now its Force Closing again and its nearly impossible to figure out why.

    Ive tried LogCat.
    Ive tried debugging mode with Eclipse, which only makes a mess of things and doesnt tell me what is going on.

    I am dumbfounded that it is this complex to get ads to work, let alone incorporate an external java library with Unity. It appears to be extremely sensitive and if a butterfly flutters in the wrong direction, everything goes nuts and explodes.

    Edit #5
    Haha Oops. Eclipse no likey if you replace files outside of eclipse or rename files.
    Last edited by Argenex; 03-23-2011 at 11:08 PM. Reason: Update

Page 1 of 9 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •